KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm using the Audio Capture sample on android.com to record and play back audio on actual devices. (Motorola touch pad, and Samsung Galaxy S). When I define the audio file path as mFile = Environment.getExternalStorageDirectory().getAbsolutePath(); record and playback works. But if I set the audio file as mFile = getFilesDir().getAbsolutePath(); OR mFile = getDir("media", Context.MODE_PRIVATE).getAbsolutePath(); OR mFile = getDir("media", Context.MODE_WORLD_READABLE).getAbsolutePath(); record seems to work, but playback fails with ERROR/MediaPlayer(4559): error (1, -2147483648) What function will return the correct internal storage directory to save audio files for playback only within my app ? The code in question is in my onCreate function. (In the example, they have it in the Constructor, but I moved it to onCreate because otherwise getFilesDir() and getDir() have no context to work.) public void onCreate(Bundle icicle) { super.onCreate(icicle); // mFile = Environment.getExternalStorageDirectory().getAbsolutePath(); // OK // mFile = getFilesDir().getAbsolutePath(); // BAD // mFile = getDir("media", Context.MODE_PRIVATE).getAbsolutePath(); // BAD mFile = getDir("media", Context.MODE_WORLD_READABLE).getAbsolutePath(); // BAD mFile += "/audiorecordtest.3gp"; Log.e(LOG_TAG,mFile); // ... } When I record to external storage (and playback works properly), the log looks like this: 06-17 10:07:3
Tags (comma-separated)
Save Edits
Cancel