I have a little problem with my app. I have a function to take picture and store it then load it in the gallery.
Before storing the picture i check if the phone has an ExternalStorage. if not the picture is saved on Files directory with getFilesDir() but i can’t load it on the gallery from internal storage.
code to load picture on gallery from ExternalStorage(rescan ExternalStorage, Work perfectly) :
path = Environment.getExternalStorageDirectory()+"";
c.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"
+ path)));
code to load picture on gallery from Filesdirectory (doesn’t load anything) :
c.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"
+ c.getFilesDir()+"/files/")));
PS: The file exists. I checked it with adb shell.
By default, files saved in internal storage (application folder – /files) are only available for the application that created them – it’s assured at filesystem level – and the Gallery app cannot load the file. When you save a new file in internal storage you must explicitly allow the file to be readable/writeable by other apps. Reference:
http://developer.android.com/guide/topics/data/data-storage.html#filesInternal
“MODE_PRIVATE will create the file (or replace a file of the same name) and make it private to your application. Other modes available are: MODE_APPEND, MODE_WORLD_READABLE, and MODE_WORLD_WRITEABLE.”