I am saving a video to public folder using
private File createVideoFile(){
if(!isExternalStorageWritable()){
return null;
}
File file = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DCIM), "vid121.mp4");
return file;
}
However I tried also PICTURES, and VIDEOS and no matter what folder I try, the video does not appear when the user opens default gallery app (or even any app that shows videos). I navigated to the folder through Files app and I can see the video.
How can I make sure the video appears as part of gallery?
Thank you
You need to rescan gallery. Because Gallery refreshed by default at boot time.
Try this.
// Tell the media scanner about the new file so that it is
// immediately available to the user.
MediaScannerConnection.scanFile(this,
new String[] { file.toString() }, null,
new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri) {
Log.i("ExternalStorage", "Scanned " + path + ":");
Log.i("ExternalStorage", "-> uri=" + uri);
}
});