Android: How to make Android gallery ignore the images of your app?

Victor Oliveira
1 min readAug 10, 2017

--

This post is a duplicate of my original blog. The purpose of this post is entirely to keep alive some posts from my old blog.

Often our applications may need to download images that should not appear in the image gallery and only be displayed by the application.

The solution to this problem is simple and can be done manually by the system user or programmatically within your application. Just create a file named .nomedia in the folder you want to not index in the image gallery.

String noMediaPath = applicationFolderPath + "/.nomedia";File noMediaFile = new File(noMediaPath);try {

if (noMediaFile.createNewFile()) {
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
}
} catch (Exception e) {
//handle exception
}

It may be necessary to clear the android image gallery cache.

--

--

Victor Oliveira

Mobile Software Engineer and Researcher at Federal University of Pernambuco