如何使用android工作室中的MediaStore Api获得特定文件夹,如android 11中的WhatsApp(



这是在android 11中获取特定路径的代码,但不幸的是,我得到了像/WhatsApp/Media/这样的路径。安卓工作室中的状态

{
Uri=collection
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
collection = MediaStore.Video.Media.getContentUri(MediaStore.VOLUME_EXTERNAL);
} else {
collection = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
}
String selection=MediaStore.Video.Media.DATA +" like?";
String[] selectionArgs=new String[]{"%/WhatsApp/Media/.Statuses%"};
String[] parameters = new String[0];
Cursor cursor = getApplicationContext().getContentResolver().query(
collection,projection,selection,selectionArgs, sortOrder)}
val STATUS_DIRECTORY = File("/storage/emulated/0/Android/media/com.whatsapp/WhatsApp/Media/.Statuses")

在中使用此获取应用程序状态

在android 11和12中,当您获得特定文件夹时,您只能使用存储访问框架权限,即运行时权限

最新更新