Do not store passwords. That is, it is impossible neither in the code, nor in the preferences, nor in the database, anywhere else at all.
With one small clarification: you can if the password is encrypted. But the question immediately arises: where to store the password from the cipher with which the password is encrypted and the circle closes :)
But not everything is so sad. There are 2 approaches:
- The most correct way: to store password hash and separately (if it is required) salt to the password.
- Encrypt the password itself, and as a password to the cipher, which encrypts the password, use the device ID, MAC address, SIM card ID, and so on. In general, to bind the encrypted contents of the password to the device, so that when a data leak is impossible to decrypt the password.