File name after MediaStore.Images.Media.insertImage
I am using MediaStore.Images.Media.insertImage(ContentResolver cr, String imagePath, String name, String description)
function to insert a newly created image into galle开发者_Go百科ry. System is naming the file by default, but it's diferent than names of pictures taken by orginal app (Time stamp). Is there easy way to set it up?
I use something like this
Uri u;
File fi = new File("/sdcard/tmp");
try {
u = Uri.parse(android.provider.MediaStore.Images.Media.insertImage(getContentResolver(), fi.getAbsolutePath(), null, null));
imageSaveName1 = u.toString();
}
imageSaveName1 looks something like "content://media/external/images/media/159"
According to the reference, insertImage
returns the URL:
Returns
The URL to the newly created image
Did it not work?
InsertImage, or just inserting ContentValues and writing to the uri, results in a file name of the date's long value.
For example I present my situation. Inserting content values where the mime type is specified as image/gif, and then writing to the resulting uri, results in a file xxxxxxxxx.jpg. The specified mime type is ignored entirely. The resulting gif image in the MediaStore does not animate and is essentially broken being displayed as a standard jpeg.
At this point I see no way to insert content values and specify a specific filename after writing to the resulting uri via a stream. Specifying the mime type in MediaScannerConnection does not help either.
精彩评论