Given a bitmap that I want to save to a special folder in the public Gallery on the phone, I tried this:
public static void saveToGallery(Context context, Bitmap bitmap) {
File path = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), File.separator + "FolderForMyApp");
path.mkdirs();
File imageFile = new File(path, "image_name.png");
FileOutputStream out = null;
try {
out = new FileOutputStream(imageFile);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
out.close();
}
catch (IOException e) {
Log.w(TAG, "Could not resolve file stream: " + e);
}
}
However it does not actually show up in the Gallery. What am I doing wrong?