views:

33

answers:

0

I used this code snippet:

ContentValues image = new ContentValues();

image.put(Images.Media.TITLE, "ImageTitle");
image.put(Images.Media.DISPLAY_NAME, "Heart");
image.put(Images.Media.DESCRIPTION, "Heart");
image.put(Images.Media.DATE_ADDED, dateTaken);
image.put(Images.Media.DATE_TAKEN, dateTaken);
image.put(Images.Media.DATE_MODIFIED, dateTaken);
image.put(Images.Media.MIME_TYPE, "image/png");
image.put(Images.Media.ORIENTATION, 0);

File parent = imageFile.getParentFile();
String path = parent.toString().toLowerCase();
String name = parent.getName().toLowerCase();
image.put(Images.ImageColumns.BUCKET_ID, path.hashCode());
image.put(Images.ImageColumns.BUCKET_DISPLAY_NAME, name);
image.put(Images.Media.SIZE, imageFile.length());

image.put("_data", imageFile.getAbsolutePath());

getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, image);

I create the image inside the cache directory of my application. I assume that the image is not copied into the media folder by the media provider and therefore not accessible from the media gallery application. Is it possible to add an image to the media gallery without writing the file to the mass storage of the phone?