In my Android App i want to save a Bitmap in the Gallery, actually that works fine with the code below. The only mistake is that when I open the image in the gallery the time created in the details is wrong. and folowing that, the image is not in the correct order in the gallery.
Has somebody an idea? Thanks a lot for help
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
Bitmap combination = //get my bitmap!
//save in gallery
MediaStore.Images.Media.insertImage(exploreActivity.getContentResolver(),combination,"test_"+ timeStamp + ".jpg",timeStamp.toString());
here a printscreen of the details :
You need to define DATE_TAKEN when inserting the image. This can be done by altering the way you add images to the gallery, and doing something like the following:
public static Uri addImageToGallery(Context context, String filepath, String title, String description) {
ContentValues values = new ContentValues();
values.put(Media.TITLE, title);
values.put(Media.DESCRIPTION, description);
values.put(Images.Media.DATE_TAKEN, System.currentTimeMillis());
values.put(Images.Media.MIME_TYPE, "image/jpeg");
values.put(MediaStore.MediaColumns.DATA, filepath);
return context.getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
}
If you need any other pointers, I would take a look at MediaStore.Images.Media.insertImage
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With