Search code examples
javaandroidandroid-assets

how to get file path of asset folder in android


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 refer my code below,

String stringPath = "android.resource//"+getPackageName()+"/raw/sample/logout.png";             
File f = new File(stringPath);

If I use the above code I got "File not found exception". So how to take image path in asset folder?


Solution

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

    MediaPlayer mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.myringtone);
    mediaPlayer.start();