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

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -