Reputation: 29266
I've got a couple of voice recordings and I'd like to play them from my code simply by telling the MediaPlayer the file to play.
Trouble is I can't find the files! The phone claims they are in "My Documents/My Recordings", as does windows when I connect the phone as a disk. But when I open that folder as a File in Java, it isn't there.
I've looked at Android.os.Environment.getExternalStorageDirectory()
and getExternalStoragePublicDirectory()
, but I haven't found the magic incantation to get to My Documents.
Any help would be much appreciated!
< Edit >
Found the files in /sdcard/My Documents/My Recordings
- so I guess the questions becomes "is there a more portable way of doing it than just hard coding /sdcard?".
Upvotes: 2
Views: 3645
Reputation: 15009
I think you want something like this:
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
This is described here. Unfortunately, there doesn't seem to be a DIRECTORY_RECORDINGS
...
Looking at your specific problem, the text suggests that getExternalStorageDirectory()
would return My Documents
on Android 4.2. Perhaps try this hack:
String myDocs = new Path(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)).getParent();
Upvotes: 1