How to add images to gallery programmatically in android or refresh gallery programmatically

后端 未结 1 635
臣服心动
臣服心动 2021-01-07 05:02

I am downloading some of the images from server to sd card in a folder. Images are storing in sd card successfully. But the problem is that at the same time images are not s

相关标签:
1条回答
  • 2021-01-07 05:32

    I got it, below code will scan your image file and make it available simultaneously to gallery also:

    MediaScannerConnection.scanFile(context,
                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);
            }
        });
    
    0 讨论(0)
提交回复
热议问题