I want to show a hidden folder having a video file in it. I know that a folder in Internal Storage is not really hidden, it is not shown by file managers having names starting with dot"."
I am using Content Resolver and Media Store to fetch all the folders/directories having video files in them. My code is working fine in fetching video folders and files except that it doesn't folder name starting with dot "." even when I manually create a folder name e.g. " .hidden_folder " and put a video file in it, still, it is not fetched.
The code I am using to fetch all video files:
@RequiresApi(api = Build.VERSION_CODES.O)
public ArrayList<MediaFiles> fetchMedia() {
ArrayList<MediaFiles> mediaFilesArrayList = new ArrayList<>();
Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
Cursor cursor = getContentResolver().query(uri, null, null, null);
if (cursor != null && cursor.moveToNext()) {
do {
String id = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media._ID));
String title = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.TITLE));
String displayName = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DISPLAY_NAME));
String path = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DATA));
String size = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.SIZE));
String duration = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DURATION));
String dateAdded = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DATE_ADDED));
MediaFiles mediaFiles = new MediaFiles(id, title, duration, size, dateAdded, path, displayName, false);
int index = path.lastIndexOf("/");
substring = path.substring(0, index);
SharedPreferences sharedPreferences = getSharedPreferences(HIDDEN_VIDEOS_PREFS, MODE_PRIVATE);
if (!allFolderList.contains(substring) && sharedPreferences.getString(HIDDEN_VIDEO_KEY + substring, "-") == ("-")) {
allFolderList.add(substring); **// This is the list having folders**
}
mediaFilesArrayList.add(mediaFiles);
}
while (cursor.moveToNext());
}
return mediaFilesArrayList; **//This is the list containg vido files**
}
I am making a Video player App in which there is an option of showing hidden files and folders. I want to search the whole Internal storage and find if there is any hidden folder and have a video file in it.
When changing the name of the folder by putting a dot in the start by using a built-in file manager of the device, it is not shown in my app and when I rename it back to the original just by removing the dot, it is showing.
Is there a right way I can fetch the hidden folders ?... I have searched everywhere....but didn't found any solution...