Reputation: 6405
How can I keep secure data from crackers in an android application? I need to use some secret keys (as the application will work through a web service) so I need to know where it would be recommended to keep this secret information and how?
Upvotes: 2
Views: 260
Reputation: 10800
You could use SharedPreferences
which is not stored in an accessible file/folder. Click here for information on SharedPreferences and here for how to use it. This is an example:
// 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);
Upvotes: 1
Reputation: 1754
You can save them in a Preferences
object and encrypt them with a hard-coded key, save them to the app's data folder and encrypt the whole file with a hard-coded key, or save them in a web location (which is probably the safest way to do it). You could also substitute a user-provided password for a hard-coded key, but that may be a nuisance depending on what the app does. If you're asking for a place that Android provides specifically for storing sensitive info, I don't believe any exists.
Upvotes: 0