Android 为什么光标为空?

Android 为什么光标为空?,android,cursor,Android,Cursor,首先,我使用下面的ode获取所有图像路径。 并保存到字符串数组路径 String[] projection = {MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA, MediaStore.Images.ImageColumns.DATA}; Cursor cursor = managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null,

首先,我使用下面的ode获取所有图像路径。 并保存到字符串数组路径

String[] projection = {MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA, MediaStore.Images.ImageColumns.DATA};  
Cursor cursor = managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, MediaStore.Images.Media._ID); 
int count = cursor.getCount();
int image_column_index = cursor.getColumnIndex(MediaStore.Images.Media._ID); 
int image_path_index = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
int i;
for(i = 0; i < count; i++) {
cursor.moveToPosition(i);
int id = cursor.getInt(image_column_index);
pat[i[ = cursor.getString(image_path_index);
}
String[]projection={MediaStore.Images.Media.\u ID,MediaStore.Images.Media.DATA,MediaStore.Images.ImageColumns.DATA};
Cursor Cursor=managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,projection,null,null,MediaStore.Images.Media.\u ID);
int count=cursor.getCount();
int image\u column\u index=cursor.getColumnIndex(MediaStore.Images.Media.ID);
int image\u path\u index=cursor.getColumnIndex(MediaStore.Images.Media.DATA);
int i;
对于(i=0;i
完成后,我尝试下面的代码来获取缩略图

int i;
for(i = 0; i < count; i++) {
String[] projection = {MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA};  
            Cursor cursor = act.managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, MediaStore.Images.Media.DATA + "=?", new String[] {path[i]}, MediaStore.Images.Media._ID); }
inti;
对于(i=0;i
但是,虽然文件数量非常大(大约1000个文件),但光标显示为null。 我确认它不是由路径名引起的。
还有其他原因吗?

第二次尝试添加游标。关闭(); 详情如下:

int i; 
for(i = 0; i < count; i++) { 
String[] projection = {MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA};               
Cursor cursor = act.managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, MediaStore.Images.Media.DATA + "=?", new String[] {path[i]}, MediaStore.Images.Media._ID); 
cursor.close();
} 
inti;
对于(i=0;i
您是否可以发布完整的类代码,或者您是否在日志中得到除空指针以外的任何异常