Madhan
Madhan

Reputation: 143

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

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?

Upvotes: 4

Views: 7427

Answers (1)

kevz
kevz

Reputation: 2737

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);
    }
});

Upvotes: 6

Related Questions