//根据音乐ID查询音乐实体对象
public MusicInfo queryById(long id) {
Cursor cursor = cr.query(Media.EXTERNAL_CONTENT_URI,
musicContent, "_id=?", new String[]{id+""}, null);
if(cursor.moveToNext()) {
Log.i(TAG, "=====");
MusicInfo info=new MusicInfo();
info._id= cursor.getInt(cursor.getColumnIndex(Media._ID));
info.displayName=cursor.getString(cursor.getColumnIndex(Media.DISPLAY_NAME));
info.title=cursor.getString(cursor.getColumnIndex(Media.TITLE));
info.duration=cursor.getLong(cursor.getColumnIndex(Media.DURATION));
cursor.close();
//返回结果
return info;
}else{
//没有数据
cursor.close();
return null;
}
}
星箜下