获取Android 2.3中的所有非媒体文件

时间:2013-11-22 12:44:05

标签: android android-contentresolver

如何获取android 2.3中的所有非媒体文件?

    ContentResolver cr = getApplicationContext().getContentResolver();
    Uri uri = MediaStore.Files.getContentUri("external");

    String selection = MediaStore.Files.FileColumns.MEDIA_TYPE + " = " + MediaStore.Files.FileColumns.MEDIA_TYPE_NONE;

    imagecursor = cr.query(uri, null, selection, null, null);

    while (imagecursor.moveToNext()) {
        count++;
    }

从上面我将获得Android 4.0及更高版本中的所有非媒体文件。但是G etContentUri(external)在Android 2.3中不起作用,它表明它在API级别11中添加了。是否有任何替代方法可以获取Android 2.3中的所有非媒体文件?

0 个答案:

没有答案