Reputation: 585
i am recording sound and saving in the sdcard in one activity.now that recording i had to play on the other next activity.i am getting the file path from Uri
and getabsolutepath()
.
but with Uri i am getting the path like
file:///mnt/sdcard/myfolder/filename.mp3
and with getabsolutepath()
i am getting path as like.
/mnt/sdcard/myfolder/filename.mp3
this thing i am getting when running app in emulator.so is there anything so that i can get the file path as /myfolder/filename.mp3.
/myfolder/filename.mp3 want to save in some string so to pass to the other activity as i had mentioned above.
thanks.
Upvotes: 2
Views: 4946
Reputation: 216
always use Environment.getExternalStorageDirectory() if you are using external storage else give path of your internal location
Upvotes: 0
Reputation: 3259
Try this,
File sdCardRoot = Environment.getExternalStorageDirectory();
File myDir = new File(sdCardRoot, "Your file name");
You will get your directory path here myDir
Upvotes: 3