how to get file path of asset folder in android

前端 未结 3 465

I have an Android application used to transfer the .png image from asset folder of Android application to my local server. I need to get the path of image in asset folder, pls r

相关标签:
3条回答
  • 2021-02-04 09:14

    Try:

    file:///android_asset/raw/sample/logout.png
    

    If you have a Context, you can use context.getAssets().open("raw/sample/logout.png") to open an InputStream on the file.

    0 讨论(0)
  • 2021-02-04 09:15

    You could put your mp3 files at : res/raw folder.

    MediaPlayer mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.myringtone);
    mediaPlayer.start();
    
    0 讨论(0)
  • 2021-02-04 09:27

    Assets and resources are accessible using file:///android_asset and file:///android_res.

     Uri path = Uri.parse("file:///android_asset/raw/sample/logout.png");
    
     String newPath = path.toString();
    
    0 讨论(0)
提交回复
热议问题