如何在android中创建隐藏目录? [英] How to create hidden directory in android?

查看:212
本文介绍了如何在android中创建隐藏目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个应用程序上工作,该应用程序创建了一些我正在通过应用程序访问的目录,出于安全考虑,我想将该目录隐藏起来.这样,用户只能在应用程序内访问它们,而不能在外部访问它们.就像通过文件管理器一样. 任何帮助表示赞赏. 不要重复,因为我搜索了所有答案,但是没有人为我工作.

I am working on an application where I have created some directory which I am accessing through my application I want to make that directory hidden for security purpose .Such that the user can access them only within the application does not access them outside the application as like through file manager. Any help is appreciated. Don't make it duplicate because I search out all the answer, but no one has worked for me.

推荐答案

仅在文件夹名称之前添加点将不会对其进行保护.它仅对用户不可见.仍然可以从应用程序(包括文件管理器,因此也包括用户)进行访问.默认情况下,大多数文件管理器都将其隐藏.

Just appending a dot before the folder name will not protect it. It is only invisible to the user. It can still be accessed from apps, including file managers and therefore the user. It's just hidden by most file managers by default.

出于安全目的要隐藏文件时,应使用Android的内部存储空间.

As you want to hide the files for security purposes, you should use Android's internal storage.

来自官方的Android开发者指南:

From the official Android developer guide:

您可以将文件直接保存在设备的内部存储中.默认情况下,保存到内部存储器的文件是您的应用程序专用的,其他应用程序无法访问它们(用户也不能访问).当用户卸载您的应用程序时,这些文件将被删除.

You can save files directly on the device's internal storage. By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user). When the user uninstalls your application, these files are removed.

示例:

String FILENAME = "hello_file";
String string = "hello world!";

FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();

Android开发人员指南

您还可以加密文件并将加密密钥存储在android Keystore中.

You could also encrypt your files and store the encryption key in the android Keystore.

此处是有关android中文件加密的好答案.
关于Android密钥库的官方指南.

Here is a good answer regarding encryption of files in android.
Official guide regarding the Android Keystore.

这篇关于如何在android中创建隐藏目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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