2011-07-30 37 views
2

我怎能从饼干安全的数据在Android应用程序?我需要使用一些秘密密钥(如应用程序将通过Web服务工作),所以我需要知道在哪里会建议保持这个秘密的信息,以及如何?我怎么能保证在Android应用程序信息

+0

你问在哪里存储Web服务的密码? – Idistic

+0

API密钥和令牌...这几乎是“密码”,就像 – Michael

回答

0

你可以将它们保存在一个Preferences对象,并将它们与硬编码的密钥来加密,将它们保存到应用程序的数据文件夹和整个文件用硬编码的密钥来加密,或者将其保存在网络位置(这可能是最安全的方式)。您也可以将用户提供的密码替换为硬编码密钥,但这可能会造成麻烦,具体取决于应用的功能。如果您要求Android提供专门用于存储敏感信息的地方,我不相信任何存在。

0

你可以使用SharedPreferences未存储在可访问的文件/文件夹。点击查看如何使用它here的信息,SharedPreferences和here。这是一个例子:

// Get settings 
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); 
// Get editor to be able to put settings 
SharedPreferences.Editor editor = settings.edit() 
// Put information with specified key 
editor.putString("example_key", "example value"); 
// Commit changes 
editor.commit(); 
// Gets value from setting with the specified key 
String exampleString = settings.getString("example_key", null); 
相关问题