一个安全的路径到外部存储 [英] A Safe Path to External Storage

查看:129
本文介绍了一个安全的路径到外部存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关我的应用程序,我需要被存储在用户的设备上的一个相当大的数据库。我打算改变这在未来。但就目前而言,我想将它存储到用户的外部存储(如果有的话),而不是填补他们的内部存储。我可以用什么方法来获得一个安全的(意思是,适用于大多数的设备)路径到外部存储?

For my app, I have a fairly large database that needs to be stored on the user's device. I plan to change this in the future. For now, however, I'd like to store it to the user's external storage (if available) rather than fill up their internal storage. What method can I use to get a safe (meaning, will work on most devices) path to the external storage?

推荐答案

您可以得到的根路径来存储DATAS。我认为这将是最安全的情况下。

You could get the root path to store your datas. I think it will be the most secure case.

String root = Environment.getExternalStorageDirectory().toString();
File dir = new File(root + "/your_folder");
dir.mkdirs();
dir.setReadOnly();

这篇关于一个安全的路径到外部存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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