查询的Andr​​oid Mediastore对于音乐文件的艺术家姓名 [英] Query the android Mediastore for Artist names of Music files

查看:71
本文介绍了查询的Andr​​oid Mediastore对于音乐文件的艺术家姓名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我撕裂有关如何实现这一点,因为内容提供商URI querys不支持简单的SQL独特的查询方法返回一个光标在mediastore歌曲的艺术家,消除任何重复的条目。

I'm torn about how to implement this because Content Provider URI querys do not support the simple SQL "DISTINCT" query method to return a cursor to the Artists of the songs in the mediastore, removing any duplicate entries.

我可以查询并获得光标到所有的艺术家,我只是撕裂至于如何去除受骗者,或者干脆不告诉他们。

I can query and get a cursor to all the artists, I'm just torn as to how to remove the dupes, or simply not show them.

我已经使用matrixcursor构造与删除的重复数据删除的条目一个新的光标尝试,但它的速度慢(建艺术家组成的数组,如果数组不复制到新matrixcursor等)

I've tried using matrixcursor to construct a new cursor with the dupe entries removed, but it's slow (build an array of artists, if in that array don't copy to the new matrixcursor, etc.)

谁能推荐一个更好的解决方案,或点我在正确的方向??

Can anyone recommend a better solution, or point me in the proper direction??

我也想过pre加载的信息,我需要到一个对象数组 - 我只是关心我的应用程序的内存开销

I've also thought about pre-loading the information i need into an array of objects - I'm just concerned with memory overhead in my application.

感谢您任何帮助,您可以提供。

Thank You for any help you may provide.

推荐答案

让所有的艺术家名单的最简单的方法(和专辑是同样的方法)是使用MediaStore.Audio.Artist的追求。例这样的事情会得到并显示所有艺术家:

The easiest way to get a list of all the artist (and albums is the same method) is to use the MediaStore.Audio.Artist for the quest. For Example something like this would get and show all the artist:

String[] proj = {MediaStore.Audio.Artists._ID, MediaStore.Audio.Artists.ARTIST, MediaStore.Audio.Artists.NUMBER_OF_ALBUMS, MediaStore.Audio.Artists.NUMBER_OF_TRACKS };
musiccursor = managedQuery(MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI, proj, null, null, MediaStore.Audio.Artists.ARTIST + " ASC");
String[] from= new String[]{ MediaStore.Audio.Artists.ARTIST, MediaStore.Audio.Artists.NUMBER_OF_ALBUMS, MediaStore.Audio.Artists.NUMBER_OF_TRACKS };
int[] to = new int[] { R.id.songname, R.id.rowlength, R.id.rowartist };
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.musicrow, musiccursor, from, to);
SongsView.setAdapter(adapter);

在哪里SongsView将是你的列表中显示它们。一切是用一个简单的游标适配器

Where SongsView would be your list to display them in. Everything else is using a simple Cursor adapter

希望这有助于

这篇关于查询的Andr​​oid Mediastore对于音乐文件的艺术家姓名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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