简体   繁体   English

Android-MediaStore ID是存储有关图片/相册信息的安全方法吗?

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

In my app I store information about an image or an image album by storing it's MediaStore id. 在我的应用程序中,我通过存储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? MediaStore ID是保存图像\\专辑信息的安全方法吗? 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 ? 1)如果删除了我存储的ID的图像/相册,是否有可能使用新的图片/相册作为该ID,导致我使用了错误的图片/相册?

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 ? 2)当图片/相册被重命名或移动时(使用手机上的文件浏览器或通过连接到笔记本电脑),其ID是否会更改?

If so...what measures do I take to avoid these errors ? 如果是这样,我应采取什么措施避免这些错误?

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. 我对此没有直接的经验,但是从这个SE答案中可以看出,当用户移动ID时,单个ID确实会更改,并且如果SD媒体已断开连接并重新连接,则所有ID都可能会更改。

Better, it seems, to store your own unique ID ( perhaps by creating a hash value ), or, more simply, the filename. 似乎更好的方法是存储您自己的唯一ID( 也许通过创建哈希值 )或更简单地存储文件名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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