Android java.lang.IllegalStateException:无法';t从游标窗口读取第0行第1列。确保光标已正确初始化

Android java.lang.IllegalStateException:无法';t从游标窗口读取第0行第1列。确保光标已正确初始化,android,Android,我正试图从图库中读取图像。我正在使用摩托罗拉G2设备和棉花糖android版本 方法: public String getPath(Uri uri) { String[] projection = {MediaStore.Images.Media.DATA}; // Cursor cursor = this.getActivity().getContentResolver().query(uri, projection, null, null

我正试图从图库中读取图像。我正在使用摩托罗拉G2设备和棉花糖android版本

方法:

public String getPath(Uri uri) {
    String[] projection = {MediaStore.Images.Media.DATA};                   

   // Cursor cursor = this.getActivity().getContentResolver().query(uri, projection, null, null, null);

    Cursor cursor = this.getActivity().managedQuery(uri, projection, null, null, null);

    int column_index = cursor.getColumnIndex(projection[0]);
    System.out.println("In Iconiq:: In postImage:: Index:: " + column_index);
    cursor.moveToFirst();

    return cursor.getString(column_index);
}

我当然会检查
cursor
是否为null,然后调用
cursor.moveToFirst()在引用所述光标之前。是的。但即使从设备库中选择了图像,光标仍返回null?@DavidM