首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MediaStore查询返回空游标

MediaStore查询返回空游标
EN

Stack Overflow用户
提问于 2015-06-13 03:45:03
回答 1查看 982关注 0票数 1

我正在尝试查询设备上所有播放列表的MediaStore;但是,我正在使用的查询返回空。我看过这个问题的解决方案,但他们只提到了正在挂载的设备,我拔下插头重新启动了设备,但问题没有得到解决。在我的问题上提供任何帮助都将非常感谢。

代码语言:javascript
复制
private void getPlaylists(){
    Cursor cursor = null;

    String[] projection1 = {
           MediaStore.Audio.Playlists._ID,
           MediaStore.Audio.Playlists.NAME
        };

        cursor = getContentResolver().query(
           MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
           projection1,
           null,
           null,
           null);

        Toast.makeText(this, cursor.getCount() + "", Toast.LENGTH_LONG).show();
  }

谢谢您:)

EN

回答 1

Stack Overflow用户

发布于 2015-06-13 22:32:28

你的代码和我的代码之间唯一的区别就是上下文的使用

代码语言:javascript
复制
 private final Uri uri = MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI;

public Cursor getandroidPlaylistcursor(Context context) {
    ContentResolver resolver = context.getContentResolver();
    final String id = MediaStore.Audio.Playlists._ID;
    final String name = MediaStore.Audio.Playlists.NAME;
    final String[] columns = { id, name };
    return  resolver.query(uri, columns, null, null,name + " ASC");
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30811035

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档