我需要从外部文件夹返回仅包含媒体的游标。
我目前正在退回手机中的所有媒体,我只需要以下位置的媒体
content://com.whereiskieran.android.spotamaster.fileprovider/root/storage/emulated/0/Pictures/Spot_A_");
任何人都可以告诉我如何创建SQL将此媒体仅返回给Cursor Loader吗?
致谢
基兰
@Override
public Loader <Cursor> onCreateLoader(int id, Bundle args) {
File file = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES) + "/" + albumName);
Uri newUri = Uri.parse(file.getPath());
String authorities = getApplicationContext().getPackageName() + ".fileprovider";
Uri imageUri = FileProvider.getUriForFile(this, authorities, file);
Uri correct = Uri.parse("content://com.whereiskieran.android.spotamaster.fileprovider/root/storage/emulated/0/Pictures/Spot_A_");
Log.d("Info", "3, Location of Spot_A_ is = " + file);
Log.d("Info", "6, newUri is =" + newUri.toString());
Log.d("Info", "7, myDir is =" + myDir.toString());
Log.d("Info", "9, imageURi =" + imageUri);
String[] projection = new String[]{
MediaStore.Files.FileColumns._ID,
MediaStore.Files.FileColumns.DATE_ADDED,
MediaStore.Files.FileColumns.DATA,
MediaStore.Files.FileColumns.MEDIA_TYPE,
MediaStore.Files.FileColumns.DISPLAY_NAME
};
String where = " _data LIKE '/Spot_A_/%'";
//What do I add to this query to return only one external folder?
String selection = MediaStore.Files.FileColumns.MEDIA_TYPE + "="
+ MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE
+ " OR "
+ MediaStore.Files.FileColumns.MEDIA_TYPE + "="
+ MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO;
String sortOrder = MediaStore.Files.FileColumns.DATE_ADDED + " DESC";
String[] selectionArgs = new String[]{"%Spot_A_%"};
Uri queryUri = MediaStore.Files.getContentUri("external");
return new CursorLoader(
this,
queryUri,
projection,
selection, // <------This line???
null,
sortOrder
);
} //End onCreateLoader