[英]Query Albums from MediaStore in android
I am developing a simple application for media in android.I want to query the albums for the media available on device.I am successful retrieving the unique names when I query on name of album with DISTINCT keyword, but we also want the other data like album_art,etc when I query more than 1 columns it gives the duplicate values. 我开发在android.I媒体的简单应用程序要查询的专辑上device.I可用的媒体是成功的检索唯一名字,当我在专辑DISTINCT关键字的名称来查询,但是我们也希望其他的数据,如当我查询多于1列时,album_art等会给出重复的值。
Here is my code 这是我的代码
String[] columns = { Albums.ALBUM, Albums._ID, Albums.ARTIST };
String selection = null;
String[] selectionArgs = null;
cursor = resolver.query(EXTERNAL, columns, selection, selectionArgs,
null);
if (cursor == null) {
} else if (!cursor.moveToFirst()) {
Toast.makeText(context, "No Media on Device", Toast.LENGTH_SHORT)
.show();
} else {
do {
String album_name = cursor.getString(0);
album = new HashMap<String, Object>();
album.put("AlbumName", album_name);
album_list.add(album);
} while (cursor.moveToNext());
}
Please help Thank You 请帮忙谢谢
Just Changed this 刚刚更改了
cursor = resolver.query(EXTERNAL, columns, selection, selectionArgs,
null);
to 至
cursor = resolver.query(Albums.EXTERNAL_CONTENT_URI, columns, selection, selectionArgs,
null);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.