I'm developing image editing App and I need to save Edited Image in Gallery of Android so user can access it and use it.
I have tried to store Bitmap into External Storage by looking up on stackoverflow. But some Android Phones like OnePlus5 Do not have external Storage. So, I have tried storing image in Internal Storage of phone Using this code. Which looks works perfectly because it returns path of stored Image in Log. In code bitmap is Bitmap of Edited image.
ContextWrapper wrapper = new ContextWrapper(getApplicationContext());
File file = wrapper.getDir("Images", MODE_PRIVATE);
file = new File(file, "DemoImg2"+ ".jpg");
try {
OutputStream stream = null;
stream = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
stream.flush();
stream.close();
}
catch (IOException e){
e.printStackTrace();
}
Uri savedImagePath = Uri.parse(file.getAbsolutePath());
Toast.makeText(getApplicationContext(), savedImagePath.toString(), Toast.LENGTH_LONG).show();
Log.i("Path:", savedImagePath.toString());
But I can't find /data/user/0/com.packagename.blurd1/app_Images/DemoImg2.jpg anywhere from file manager. Saved Image also does not appear anywhere in Gallery . After searching about it, I know that only app, that stored image itself, can access image stored in Internal Memory and user can't access it. So what should I do to save Bitmap Image into gallery Directly even if android phone does not have external storage. I can't find any answer about it anywhere.