我正在为android开发一个简单的媒体应用程序。我想查询设备上可用媒体的相册。当我查询名称的相册时,我成功检索了唯一的名称strong> DISTINCT 关键字,但是当我查询超过1列时,我们还想要其他数据,例如album_art等,它会给出重复值。
这是我的代码
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());
}
请帮忙 谢谢
答案 0 :(得分:0)
刚改变了这个
cursor = resolver.query(EXTERNAL, columns, selection, selectionArgs,
null);
到
cursor = resolver.query(Albums.EXTERNAL_CONTENT_URI, columns, selection, selectionArgs,
null);