I am attempting to save recorded audio from an application to the storage device using MediaRecorder.
When I used internal storage (/data/data/com.example.app/files) I got random MediaRecorder errors. These errors were resolved by changing the save location to
String files_dir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myapp_audiofolder/";
This works fine except that other applications have access to this folder. For instance, my Google Music app included the audio from this folder in the music listings.
What is the proper way to store data like this so only my application will have access to it?
The Android documentation has a page dedicated to data storage, and here you can find the section on using the internal storage to save application data. As long as you call
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);with theContext.MODE_PRIVATEparameter as shown in their example, only your app will be able to access the file.