In one part of my app i need to save captured pictures by user and place them in a folder i want to create so i can query that folder later and pick the last picture in it and show it to user as an overview. i know that i can save pictures in public shared pictures folder like this:
ContentValues contentValues = new ContentValues();
contentValues.put(MediaStore.Images.Media.RELATIVE_PATH,
Environment.DIRECTORY_PICTURES);
contentValues.put(MediaStore.Images.Media.IS_PENDING, true);
ContentResolver contentResolver = context.getContentResolver();
Uri uri = contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
contentValues);
if (uri != null) {
//convert the pic as byte array to bitmap
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
try {
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, contentResolver.openOutputStream(uri));
contentValues.put(MediaStore.Images.Media.IS_PENDING, false);
contentResolver.update(uri, contentValues, null, null);
} catch (Exception e) {
}
}
But the problem is if there is any other picture in the shared folder my app would pick the last one and show it regardless of it being captured by my app or other apps
My question is do we have any way to create folder in android? (other than data folder or use MANAGE_EXTERNAL_STORAGE permission)
or we just have to use public shared folderd without any inner folder because i've tried MediaStore
and File
Api and i can't do it.