Requirements of app:
- Saved files visible in stock device's file browser. (for user manipulation)
- Files are deleted when app is uninstalled.
I came across this post (How can I let users access the internal storage directory of my app?) where the OP seemed to be wanting the same behavior I do and seemed to have it solved by using getExternalFilesDir() [last post] but when I use that method my files are not visible to the user outside of my app. So how do I get both functionalities in my app?
externalDir = mContext.getExternalFilesDir(null);
File myDir = new File(externalDir.toString() + "/my_snapshots");
myDir.mkdirs()
String fname = "Image-" + n + ".jpg";
File file = new File(myDir, fname);
FileOutputStream out = new FileOutputStream(file);
MediaScannerConnection.scanFile(mContext, new String[] { file.toString() }, null,
new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri) {
Log.i("ExternalStorage", "Scanned " + path + ":");
Log.i("ExternalStorage", "-> uri=" + uri);
}
});