Android: Check if file already exists in MediaStore -



Android: Check if file already exists in MediaStore -

i'm storing image in media store (to enable sharing) using code below:

public static uri storeinmediastore(context context, bitmap bitmap, string title) { contentvalues values = new contentvalues(); values.put(images.media.title, title); values.put(images.media.bucket_id, "xxx"); values.put(images.media.description, "shared via xxx"); values.put(images.media.mime_type, "image/jpeg"); uri uri = context.getcontentresolver().insert(media.external_content_uri, values); outputstream outstream; seek { outstream = context.getcontentresolver().openoutputstream(uri); bitmap.compress(bitmap.compressformat.jpeg, 70, outstream); outstream.close(); } grab (filenotfoundexception e) { } grab (ioexception e) { } homecoming uri; }

which found in stackoverflow. code works problem is, every time user clicks share button, store new image redundant.

what need check if image title , description exists (title combination of app name, file name , date , unique per image) , if so, homecoming existing uri , if not, create, save , homecoming new uri (which above code doing).

has done before or knows how query media store title , description?

many thanks,

android

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -