简体   繁体   中英

Images _display_name is changed in external db at com.android.provider.media/external.db

I am using MediaStore.Images.Media.EXTERNAL_CONTENT_URI(External DB :: data/data/com.android.provider.media/external.db)) in my app to save images with my own _display_name for example : image_101.jpg but after some time the display name is change into long no. like 1327392947034.jpg. and next time when i fetch the image with my _display_name(image_101.jpg) it found nothing in external db. can anyone tell me why it happens ?

Thanks

I believe this happens when the MediaScanner adds the file to the internal MediaStore. I think the numbers are related to System.currentTimeMillis(); (salted hash, or similar). I think this is to reduce the likely-hood of filename collision (two images with the same name).

There should be a way to separate display names from file names however. When you say "my _display_name" are you referring to a column in the MediaStore you "added" (eg "data2") ? Or are you using the DISPLAY_NAME ( android.provider.MediaStore.MediaColumns ) column? You could also look at putting you custom name in the DESCRIPTION column.

One workaround would be to keep your own db of display names with a column for the ID in the Media store.

Also how are you inserting the image? Are you using an SQL query or one of the:

insertImage(ContentResolver cr, String imgPath, String name, String desc)

methods from MediaStore.Images.Media ?

A bit more code would help but maybe some of this answer can help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM