Reputation: 75
I'm currently working on an app, and on the home screen, there should be something like this: https://i.sstatic.net/RqzLw.png So my question is: how do i store that data in the android device? I did not find anything helpfull on google, all i got is mysql data storage. Thanks.
Upvotes: 0
Views: 87
Reputation: 2166
You can use SharedPreferences to easily save and load simple values such as Strings, see below:
Saving a String
SharedPreferences prefs = context.getSharedPreferences("app", MODE_PRIVATE);
Editor edit = prefs.edit();
edit.clear();
edit.putString("password", txtPass.getText().toString().trim());
edit.commit();
Loading
SharedPreferences userDetails = context.getSharedPreferences("app", MODE_PRIVATE);
String pass = prefs.getString("password", null);
If you're storing passwords you might want to look into more secure methods or use encryption/decryption techniques when saving and loading.
Upvotes: 1
Reputation: 806
You can use Shared Preferences, but it's not adviced to save sensitive informations (such as passwords) in a phone.
Even you would encrypt a password, it could easily be decrypted back because Android apps can easily be decompiled.
Upvotes: 0