Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 游标在查询时总是返回null_Android_Android Contentprovider_Android Cursor - Fatal编程技术网

Android 游标在查询时总是返回null

Android 游标在查询时总是返回null,android,android-contentprovider,android-cursor,Android,Android Contentprovider,Android Cursor,我正在使用意图从我的Android设备中选择一个文件。当显示选择器时,我选择Astro文件管理器,然后继续选择一个文件(本例中为视频) 我得到一个URI(content://com.metago.astro.filecontent/file/file/sdcard/Download/video_video.mp4)我尝试用以下方法处理它: Cursor cursor = null; final String column = null; final String[] pr

我正在使用意图从我的Android设备中选择一个文件。当显示选择器时,我选择Astro文件管理器,然后继续选择一个文件(本例中为视频)

我得到一个URI(
content://com.metago.astro.filecontent/file/file/sdcard/Download/video_video.mp4
)我尝试用以下方法处理它:

    Cursor cursor = null;
    final String column = null;
    final String[] projection = null;

    try {
        cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);

        if (cursor != null && cursor.moveToFirst()) {
            // Never enters here because cursor always null
            L.p("Hi!");
        }
    } catch (Exception e) {
        L.p(e.getMessage()); // Never hit
    } finally {
        if (cursor != null)
            cursor.close();
    }

然而,游标总是返回
null
。知道为什么会发生这种情况吗?

也许Astro不支持
OpenableColumns
。我想,至少如果你在用来“选择文件”的
Intent
上有
CATEGORY\u OPENABLE
,它们应该是可以打开的但我仍然得到
null
。您确定这不会引发异常吗?您不会显示
catch
块以及是否正在记录任何内容。是的,它为null,但不会引发异常。我已经更新了代码片段。PS谢谢你的时间。根据你的描述,这似乎是Astro中的一个bug。你可以联系他们,看看他们有什么要说的。或者,或者解决无法检索
OpenableColumns
这一事实。这些仅提供显示名称和大小。对于显示名称,使用
Uri
上的
getlastpathsgment()
剪掉文件名,因为它们的
Uri
恰好是这样工作的。