In my application I use the code below to list movies in Movies
folder in storage. But since I upgraded my Nexus 7 tablet to Android 4.4 this code is not working (the toast at the end of the code pops up meaning the code did not find any files in that folder, of I dont know even if it can access that folder). Any idea what should I change or what is changed in the new update?
private void populateSpinners() {
Boolean foundVideoFiles;
// videos spinner
File videoFolder =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES)
.getAbsoluteFile();
if (videoFolder.listFiles() != null) {
foundVideoFiles = true; //found some files
ArrayAdapter<File> movieAdapter = new ArrayAdapter<File>(this,
android.R.layout.simple_spinner_dropdown_item, videoFolder.listFiles());
_spinner_videos.setAdapter(movieAdapter);
//Restore perviously selected video
int spinnerValue = _preferences.getInt("spinner_videos", -1);
if (spinnerValue != -1) {
_spinner_videos.setSelection(spinnerValue);
}
} else {
foundVideoFiles = false;
}
//Error handling
if (foundVideoFiles == false) {
Toast.makeText(this, "ERROR: NO MOVIES WERE FOUND IN" + videoFolder, Toast.LENGTH_LONG).show();
}
}
If I use the Gallery app on the tablet, I can see the movies there, so the movies have not been erased during update.