图片权限(不要在图库中使用它们) [英] image permissions (don't want them in gallery)

查看:213
本文介绍了图片权限(不要在图库中使用它们)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个将其图像存储在Android / data文件夹中的应用程序。
图片在图库中可见,但我不想这样。

I'm working on a application which stores its images in the Android/data folder. The pictures are visible in the gallery, but I don't want that.

是否可以设置文件夹的权限,以便只能使用它们应用程序本身,还是应该将它们存储在另一个文件夹中?

Is it possible to set permissions on a folder so they can only be used by the application itself, or should I just store them in another folder?

推荐答案

创建一个名为的文件文件夹中的.nomedia 。这会将它们隐藏在图库应用程序中。

Create a file called .nomedia in the folder. That'll hide them from the gallery application.

以下是如何在Java代码中执行此操作:

Here's how to do it in Java code:

File nomedia = new File(dataFolder, ".nomedia");
try {
    nomedia.createNewFile();
} catch (IOException e) {
    e.printStackTrace();
}

这篇关于图片权限(不要在图库中使用它们)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆