Shared Preferences

The next implementation is to hide the key in the shared preferences and then load it each time the app is opened. There are two variations on this theme. A typical app will ask the user to encrypt the app the first time and save the key in the shared preferences. Listing 5-5 shows how to write and load our encryption key from a shared preferences file.

Listing 5-5 Storing passwords in the shared preferences file

private void saveLastSuccessfulCreds() {    String username =((EditText) findViewById(R.id.username_field)).getText().toString();    String password =                                               // line 3((EditText) findViewById(R.id.password_field)).getText().toString();    SharedPreferences.Editor ...

Get Bulletproof Android™: Practical Advice for Building Secure Apps now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.