My application store images in a private folder /sdcard/Android/data/com.mypackage.myapp/files/. I want to add those picture to the gallery. I tried adding them to the media store but it creates a folder for each folder I have in my private directory. I want more control on the name/structure of the albums. I think I'm supposed to use a content provider for this, but I'm not sure what to do next. The snippet I'm using is the following :
ContentValues values = new ContentValues(4);
long current = System.currentTimeMillis();
values.put(MediaStore.Images.Media.TITLE, file.getName());
values.put(MediaStore.Images.Media.DATE_ADDED, (int) (current / 1000));
values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpg");
values.put(MediaStore.Images.Media.DATA, file.getAbsolutePath());
ContentResolver contentResolver = context.getContentResolver();
Uri base = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
Uri newUri = contentResolver.insert(base, values);
// Notify the media application on the device
context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, newUri));
This works great but doesn't give me control on the folder structure. How can I add my images to the gallery with a folder structure different from the file structure like google does with "picasa" (and how to put a custom icon for folders like the picasa icon below)