简体   繁体   English

如何在Android中以编程方式隐藏文件夹并访问其中的文件。

[英]How to hide a folder using programmatically in android, and access there file.

I am developing android application which having some external files. 我正在开发具有一些外部文件的android应用程序。 I want to hide these files. 我想隐藏这些文件。 Can we access hidden file in my app. 我们可以访问我的应用程序中的隐藏文件吗? Example I have many of images which will be use in my app. 示例我有许多将在我的应用程序中使用的图像。 I want to hide these file but access only using my app. 我想隐藏这些文件,但只能使用我的应用程序访问。

Just put a . 只要放一个. in front of your folder name than it becomes a hidden folder 在您的文件夹名称前面,它将变为一个隐藏文件夹

Android is multi user linux system, so if you create folder starting with dot , it'll be hidden. Android是多用户linux系统,因此,如果您创建以dot开头的文件夹,它将被隐藏。

So store folder starting with dot 因此,存储以dot文件夹

for example 例如

File folder = new File(Environment.getExternalStorageDirectory(), ".hiddenFolder");
folder.mkdir();

and store all images in this folder and access images in your app from same folder. 并将所有图像存储在此文件夹中,并从同一文件夹访问应用程序中的图像。

Create a folder with a . 用创建一个文件夹。 (dot) before its name, and add an empty .nomedia file inside it. (点)之前,然后在其中添加一个空的.nomedia文件。 (.(dot)nomedia - exactly as I typed it) and add your files ands images there. (。(dot)nomedia-正是我键入的内容),然后在其中添加文件和图像。

Now other Apps like Gallery will ignore these images. 现在,其他应用程序(例如图库)将忽略这些图像。 That's the only way that I think this can be done. 这是我认为可以做到的唯一方法。

Eg: folder name: .images 例如:文件夹名称:.images

which includes an empty file .nomedia 其中包括一个空文件.nomedia

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM