Check the "Credential Processing" section of the Android Developer's Guide. . I will bring it here.
If possible, the username and password should not be stored on the device. Instead, perform initial authentication using the user name and password provided by the user, and then use the short-lived , specialized authorization token ..
Services available across multiple applications can be accessed using the AccountManager . If possible, use the AccountManager class to invoke the cloud service and do not store passwords on the device.
After using the AccountManager to retrieve the Account , CREATOR before transferring any credentials so that you do not accidentally transfer credentials to the wrong application.
If the credentials should only be used by the applications you create, you can check the application that accesses the AccountManager using checkSignature () . Alternatively, if only one application will use credentials, you can use KeyStore for storage.
source share