如何让文件隐藏在android SD卡中?
我正在创建 android
应用程序,其中包含需要隐藏在 SD 卡中(用户无法访问)的数据库。 谁能告诉我该怎么做?
I am creating android
application which contains DB that needs to be hidden(not able to access by the user)in the SD Card. Can anyone tell me how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
存储在 SD 卡上的任何文件都可以由手机上运行的应用程序以及安装了 SD 卡的用户(无论是在手机中还是在其他情况下)访问。
您可以更改文件属性以使其“隐藏”,但仍然可以轻松找到它。 无法以您描述的方式使 SD 卡等公共分区上的文件“安全” - 用户始终能够复制、删除和可能更改文件。
解决您的问题的最佳方法是研究加密数据库以安全记录的方法。 您将无法阻止用户删除或复制该文件,但您应该能够使他们难以从中读取数据或修改其内容。
Any file stored on the SD card is accessible both by applications running on the phone, and by users who have mounted the SD card (both while it's in the phone and otherwise).
You can change the file properties to make it 'hidden', but it will still be easily found. There is no way to make a file on a public partition like an SD Card 'secure' in the manner you describe - users will always be able to copy, delete, and potentially change the file.
The best solution to your problem is to look into ways to encrypt your database to record it securely. You won't be able to prevent users from deleting or copying the file, but you should be able to make it difficult for them to read data from it or modify its contents.
为了一个简单的解决方案,只需在 db 文件前面加上 . (如 .dbfile)。 这将在基于 Linux 的系统(包括 android)上隐藏该文件。
我假设您想隐藏该文件以防止用户意外删除/更改它。
For an easy solution, just prefix the db file with a . (like .dbfile). This will hide the file on Linux based systems, including android.
I am assuming that you want to hide the file to prevent users from accidentally deleting/changing it.
SD 卡无法按照您所寻求的方式进行保护。
SD cards cannot be secured in the fashion you seek.
只需将文件命名为以 ."Dot"...".myFolder/.myfile" 开头
just name the file start by ."Dot"... ".myFolder/.myfile"
您可以创建一个名称以点(.)开头的文件夹,例如(.dbfiles)android将这些文件夹视为配置文件夹,并且不要在画廊,音乐播放器等应用程序中显示这些文件夹的内容...您可以使用以下命令查看这些文件夹高级文件浏览器,例如 Es 文件浏览器
You can create a folder whose name starts with a dot(.) example (.dbfiles) android See these folders as configuration folder and do not show content of these folder in applications like gallery,music player...You can see these folders with advance file explorer like Es File explorer
SD卡你不能! 内部应用程序数据分区是适合您的地方。
Sdcard you cant't! Internal app data partition is the place for you.