如何更新Android的媒体数据库 [英] How to update the Android media database

查看:567
本文介绍了如何更新Android的媒体数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序显示歌曲的SD卡列表中,有一个选项,从SD卡中删除的歌曲。

My application shows the list of songs in sdcard, and there is an option to delete the song from SD card.

即使当歌曲被删除的歌曲仍然来自于我的应用程序列表。

Even when the song is deleted the song still comes in my applications list.

我怎么可以更新Android的媒体数据库并显示更新的数据库?

How can I update the android media database and show the updated database?

推荐答案

Android有各种各样的缓存,它跟踪的媒体文件。

Android has a cache of sorts that keeps track of media files.

试试这个:

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));

这使得MediaScanner服务运行一次,这应该从设备的缓存中删除已删除的歌曲。

It makes the MediaScanner service run again, which should remove the deleted song from the device's cache.

您还需要这个权限添加到您的Andr​​oidManifest.xml:

You also need to add this permission to your AndroidManifest.xml:

<intent-filter>
  <action android:name="android.intent.action.MEDIA_MOUNTED" />
  <data android:scheme="file" /> 
</intent-filter>

这篇关于如何更新Android的媒体数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆