I am building a chat application using socket.io. I want the images sent by the user to be viewed in the gallery.
I am currently using following code to save the image in application directory. how can I view images stored in "/data/data/com.example.diksha.chatapplication/" directory in gallery?
Code for saving the image
private Uri saveImage(Bitmap image){
File directory = getContext().getFilesDir();
String id = UUID.randomUUID().toString();
File path = new File(directory, id + ".jpg");
Log.d(TAG, "saveImage: " + path);
try {
FileOutputStream out = new FileOutputStream(path);
image.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.close();
}catch (Exception e) {
e.printStackTrace();
}
return FileProvider.getUriForFile(getContext(),getContext().getPackageName() + ".fileprovider", path);
}