从应用程序本身之外被访问保护文件 [英] Protect files from being accessed outside the app itself

查看:103
本文介绍了从应用程序本身之外被访问保护文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个Android应用程序,在这里我下载的PDF文件。
所以我创建了一个名为 NameProject ,我把所有的PDF文件下载文件。我可以通过我的应用程序,并通过类似文件管理器其它应用访问该文件。
Android的文件系统是开放的,所以我需要保护下载的文件从应用程序本身之外被访问。

I am developing an android application, where I download pdf files. So I create a file called NameProject where I put all downloaded pdfs. I can access this file via my application and also via other application like File Manager. The android file system is open so I need to protect downloaded files from being accessed outside the app itself.

我能做到这一点?如果是的话,任何想法将AP preciated。

Can I do that? If yes, any ideas will be appreciated.

感谢

推荐答案

下载文件到应用程序内部存储目录(/数据/数据​​/的软件包名的),这应该是没有根permition无法访问。但请有只在必要的文件尽可能多的手机有小型的内部memmory。

Download file to the application internal storage directory (/data/data/packagename) which should be not accessible without root permition. But keep there only necessary files as much phones have small internal memmory.

File appdir = context.getDir("mydir", Context.MODE_PRIVATE);

文件fil​​eWithinAppDir =新的文件(APPDIRappfile);

这篇关于从应用程序本身之外被访问保护文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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