Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why the downloaded video from an android app not showing in the Gallery?

Tags:

android

video

In my application, I have downloaded a video from the web and save it in the device's Internal storage. I can see the video file in the folder where I stored the video using the File Explorer app. But the gallery app in my mobile doesn't list the video from saved from my app. The gallery app lists the video I have downloaded from other apps like WhatsApp. What is the reason?

To see the video saved from my application in the gallery app, whether I need to set any permission in my app?

like image 238
Madhan Avatar asked Sep 12 '25 12:09

Madhan


1 Answers

Just add below line after you save the video file -

For api < 14

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + 
Environment.getExternalStorageDirectory())));

for api >= 14

MediaScannerConnection.scanFile(MainActivity.this, 
new String[] { Environment.getExternalStorageDirectory().toString() }, 
null, 
new MediaScannerConnection.OnScanCompletedListener() {

    public void onScanCompleted(String path, Uri uri) {

              Log.i("ExternalStorage", "Scanned " + path + ":");
              Log.i("ExternalStorage", "-> uri=" + uri);
    }
});
like image 200
kevz Avatar answered Sep 15 '25 04:09

kevz