应用的私人文件 [英] Private file for an app

查看:76
本文介绍了应用的私人文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个文件,其中存储了一些只能由我的应用访问的数据。外部用户不应访问该文件或对其进行任何更改。我将在文件中存储一个密钥

I would like to create a file which stores some data that can be accessed only by my app.Outside users should not be able to access this file or make any changes to it.I will store a key in the file which maybe accessed by the app whenever needed.

推荐答案

要创建应用程序私有文件(其他应用程序无法读取),则应使用 Context.openFileOutput()带有标志 MODE_PRIVATE

To create an application private file (that is not readable by other applications) you should use Context.openFileOutput() with a flag MODE_PRIVATE.

如果您担心,可以将返回的InputStream包装在 CiperOutputStream 并对内容进行加密。

If you are concerned you could wrap the returned InputStream in CiperOutputStream and encrypt the contents.

如果您以标准加密格式(X.5 09或PKCS#12),则可以使用新引入的 KeyChain API ICS。

If you are storing keys in a standard crypto format (X.509 or PKCS#12) you could use the new KeyChain API introduced in ICS.

这篇关于应用的私人文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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