删除某些项目后,MediaStore 中的 ID 会发生什么情况?

发布于 2024-08-30 06:19:04 字数 204 浏览 3 评论 0原文

假设:我从 SD 卡中删除了一个项目,然后卸载了存储卡。

当 Android 重新扫描我的 SD 卡以进行更改时会发生什么情况?在 MediaStore 中,每一行都有一个 _ID,因此在删除一个项目后,该 _ID 会发生什么情况:

  • 它是否保留在 MediaStore 中,是否与另一个项目关联,或者,
  • 它被永久删除?

Let's suppose that: I delete an item from my sd card and then, I unmount the memory card.

What happens when Android rescans my sd card for changes? In MediaStore, every row has a _ID so after I delete an item what happens to this _ID:

  • Does it remain in MediaStore, it is associated with another item, or,
  • It is removed permanently?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终止放荡 2024-09-06 06:19:04

我有同样的问题,找出答案的最好方法就是进行测试。

根据我所看到的,它的工作原理如下:

1)id从1开始,当媒体扫描仪添加新图像或视频时,id增加12

)如果您删除文件并且mediascanner还不知道这一点,您将尝试从 mediastore 获取,记录仍然会在那里

3) 一旦 mediascanner 发现该文件消失,它将从 mediastore 数据库中删除该记录

4) 删除的记录的 id 将不会被使用,所以如果您有三个项目ids 1,2,3 并删除项目 2 并添加一个新项目,列表将看起来像 1,3,4 - 因此删除的 ids 将不会被重用

I had the same question and the best way to find out the answer is to do the test.

based on what I saw, it works like that:

1) id is started on 1 and increments by 1 when new images or videos are added by media scanner

2) if you delete the file and mediascanner does not know about that yet and you will try to fetch from mediastore, the record still will be there

3) once mediascanner sees that file is gone, it will remove the record from mediastore db

4) the id of the removed record won't be used so if you had three items with ids 1,2,3 and drop item 2 and add a new one, the list will look like 1,3,4 - so deleted ids won't be reused

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文