The SharedPreferences API is commonly used to permanently save small collections of key-value pairs. Data stored in a SharedPreferences object is written to a plain-text XML file.
File file = new File (Environment.getExternalFilesDir(), "password.txt");String password = "SecretPassword";FileOutputStream fos; fos = new FileOutputStream(file); fos.write(password.getBytes()); fos.close();
KeyStore API
The Android KeyStore supports relatively secure credential storage. As of Android 4.3 (API level 18), it provides public APIs for storing and using app-private keys.
An app can use a public key to create a new private/public key pair for encrypting application secrets, and it can decrypt the secrets with the private key.