Im building a pp for photo editing. i want to create my app folder in gallery and when user click on save button the images should be saved to my app specified folder in gallery, i make it possible with media storage with this line values.put("_data", file.getAbsolutePath());, BUT the problem is that these images in gallery are not showing, they are showing a 404 type error, i think this is a permission issue, but im storing the file in to my app specified folder with getExternalFileDir() than im showing this folder in gallery why there is a permission issue as im working in my app specific folder, here im sharing my code
String resultPath = getExternalFilesDir(null)+ getString(R.string.directory) +
System.currentTimeMillis() + ".jpg";
File file = new File(resultPath);
file.mkdirs();
try {
OutputStream fileOutputStream = new FileOutputStream(file);
savedBitmap.compress(CompressFormat.JPEG, 100, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
} catch (IOException e2) {
e2.printStackTrace();
}
savedBitmap.recycle();
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, "Photo");
values.put(MediaStore.Images.Media.DESCRIPTION, "Edited");
values.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis ());
values.put(MediaStore.Images.ImageColumns.BUCKET_ID, file.toString().toLowerCase(Locale.US).hashCode());
values.put(MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME, file.getName().toLowerCase(Locale.US));
values.put("_data", file.getAbsolutePath());
ContentResolver cr = getContentResolver();
cr.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);