简体   繁体   English

我可以在Android中创建受密码保护的文件夹吗?

[英]Can I create password protected folder in Android?

I would like to create a folder which is password protected. 我想创建一个受密码保护的文件夹。 I am able to create a folder in the following way, but how can I create a password protected folder? 我可以通过以下方式创建文件夹,但是如何创建受密码保护的文件夹?

File nf = new File("/sdcard/NewFolder");
nf.mkdirs();
  • in android there is not possible but we can hide using "." 在android中是不可能的,但是我们可以使用“。”隐藏。 at prefix 在前缀
  • otherwise Store important folder or file in internal memory. 否则,将重要的文件夹或文件存储在内部存储器中。
  • you can see you package directory following way String dir = getPackageManager().getPackageInfo("com.example.kinkey", 0).applicationInfo.dataDir; 您可以通过以下方式看到软件包目录:String dir = getPackageManager()。getPackageInfo(“ com.example.kinkey”,0).applicationInfo.dataDir;

Note: it is visible on windows pc 注意:在Windows PC上可见

You can't create such a folder on sdcard. 您无法在sdcard上创建这样的文件夹。 Everything that's saved onto sdcard can be accessed by other applications. 保存到sdcard上的所有内容都可以被其他应用程序访问。 If you want to create a folder which is not accessible from outside of your application use Context.getDir() method with mode set to MODE_PRIVATE : 如果要创建无法从应用程序外部访问的文件夹,请使用Context.getDir()方法(其模式设置为MODE_PRIVATE)

Context ctx = getContext();
File folder = ctx.getDir("NewFolder", Context.MODE_PRIVATE);

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

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