Android - Is MediaStore ID a safe way to store information about pics/albums?

吃可爱长大的小学妹 提交于 2019-12-24 16:32:25

问题


In my app I store information about an image or an image album by storing it's MediaStore id. Later on I may have to perform operations that require these images/albums. Is the MediaStore id a safe way to keep image\album information? More specifically:

1) If an image/album whose id I have stored gets deleted, is it possible a new picture/album could take this id resulting in me using the wrong picture/album ?

2) when pictures/abums are renamed or moved ( using a file browser on the phone or by connecting to a laptop) do their ids change ?

If so...what measures do I take to avoid these errors ?


回答1:


I've not had direct experience with this, but appears from this SE answer that individual IDs do change when the user moves them, and all IDs may change if the SD media is disconnected and reconnected.

Better, it seems, to store your own unique ID (perhaps by creating a hash value), or, more simply, the filename.



来源:https://stackoverflow.com/questions/27201489/android-is-mediastore-id-a-safe-way-to-store-information-about-pics-albums

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!