使用 Android MediaStore 管理媒体

发布于 2024-08-31 04:25:46 字数 162 浏览 3 评论 0原文

我直接管理应用程序的媒体(图像、声音),读取并保存到 SD 卡。我应该使用 MediaStore 吗?我不太确定 MediaStore 的用途,并且 javadoc 也不是很有帮助。

应用程序何时应使用 MediaStore?如果能简要概述一下 MediaStore 的优缺点,我们将不胜感激。

I manage media (images, sound) of my app directly, reading and saving to the SD card. Should I be using the MediaStore instead? I'm not quite sure what the MediaStore is for, and the javadoc is not very helpful.

When should an app use the MediaStore? A brief overview of the pros and cons of the MediaStore will be much appreciated.

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

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

发布评论

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

评论(2

九公里浅绿 2024-09-07 04:25:46

作为一个狂热的安卓用户。

我认为 MediaStore 是内部 Android 媒体扫描仪应用程序(您可以通过备件手动调用它)和第 3 方应用程序(例如您的应用程序)之间的“公共链接”。

我猜测 MediaStore 是基于其 android.provider 包装的“公共链接”。

作为 android 中的提供者,应用程序如何向其他应用程序提供信息

如果 MediaStore 是 ContentProvider,则读取由 MediaScanner 填充的信息。

然后MediaStore用于用户媒体,例如音乐,视频,图片等。

用于铃声,通知;我认为你应该使用 android.media.RingtoneManager

也不要硬编码路径“/sdcard/” 有一个 api 调用来获取它,Environment.getExternalStorageDirectory()

http://twitter.com/cyanogen/status/13980762583

====

优点是每次将可移动存储安装到时,媒体扫描仪都会运行手机,它还会扫描内部存储器(如果有像 HTC EVO 那样的内存)

As an avid android user.

I think MediaStore is the "Public Link" between the internal Android Media Scanner Application (You can manually invoke it through Spare Parts) and 3rd party applications, like yours.

I'm guessing MediaStore is this "public link" based on its android.provider packaging.

As providers in android, is how applications provide information to other applications

If MediaStore is a ContentProvider, reading information populated by MediaScanner.

Then MediaStore is for User media, such as music, video, pictures etc.

For ringtones, notifications; I think you are supposed to use android.media.RingtoneManager

Also don't hardcode the path "/sdcard/" There is an api call to get it, Environment.getExternalStorageDirectory()

http://twitter.com/cyanogen/status/13980762583

====

The pro is that Media Scanner runs every time you mount the removable storage to the phone, and it also scans the internal memory (if it has any like the HTC EVO & incredible)

梦情居士 2024-09-07 04:25:46

我不是这方面的专家,但就我的常识而言,这是搜索某些类型文件的简单方法。

如果您的应用程序有某种库,那么使用 MediaStore 而不是自己搜索所有内容更有用、更快且耗电更少。您也可以放心,这些是系统中存在的所有文件。

我希望这有帮助。

I am no expert in this but as far as my common sense goes, well its the easy way to search for certain types of files.

If your app has a library of sorts, then using MediaStore instead of searching all by yourself is more useful, faster and less power consuming. Also you can be assured that those are all the files present in the system.

I hope this helps.

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