[英]MediaStore.Images.Media.INTERNAL_CONTENT_URI returns empty cursor
I have code to get all images from external by MediaStore.Images.Media.EXTERNAL_CONTENT_URI
and internal by same (but internal instead of external) 我有代码通过
MediaStore.Images.Media.EXTERNAL_CONTENT_URI
从外部获取所有图像,并通过相同的方式获取内部(但内部而不是外部)
In my device android version 7.0 all images in external and internal returned by external cursor and like question title internal returns empty cursor and i am 100% that i have lots of images in internal 在我的设备android版本7.0中,外部光标返回的外部和内部所有图像,就像问题标题内部返回的空光标一样,我100%表示内部有很多图像
Big Strange Prob that same code works fine with another device android version 5.1 internal returns internal images and external returns it's own imgs so where is the problem i don't get it .... Big Strange Prob ,同一代码可与另一台设备android 5.1版正常工作,内部返回内部图像,外部返回其自身的img,所以问题出在哪儿我不明白...
how same code works differently on 2 real devices(no emulators here) 同一代码在2个真实设备上的工作方式不同(此处没有仿真器)
Code of both cursors is below 两个游标的代码如下
cursorEx = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
projection, null, null, DATE_DESC_SORT_ORDER);
cursorIn = getContentResolver().query(MediaStore.Images.Media.INTERNAL_CONTENT_URI,
projection, null, null, DATE_DESC_SORT_ORDER);
Probably you did not asked for permission in android 7. Its mandatory! 可能您未在android 7中请求权限。它是强制性的! You can either ask for permission, or target a SDK less than 22.
您可以请求权限,也可以定位小于22的SDK。
if (ContextCompat.checkSelfPermission(ProfileActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(ProfileActivity.this,
Manifest.permission.READ_EXTERNAL_STORAGE)) {
// Explain to the user why we need to read the contacts
}
ActivityCompat.requestPermissions(ProfileActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST);
// MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE is an
// app-defined int constant that should be quite unique
return;
}else {
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
startActivityForResult(Intent.createChooser(intent,
"Selecione a foto "), select_image_code);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.