In my project want to read and write the data in server depends upon the authentication key(user).
So far I planned to use shared preference to store user authentication key for further communication with server.
Later I came to know "Account manager" by reading this tutorial:
I have little confuse to use account manager or sharedpreference.
I feel little difficult to understand accountmanager.
Can any one guide which method suits for my project.
Any tutorial for account manager.?
Any other suggestions...?
Thanks in advance.
SharedPreferences ? Looks like they are for similar things - you can put and get a value by a key in both of them, but Preferences looks like something more difficult and belongs more to the OS than to an app.
A SharedPreferences object points to a file containing key-value pairs and provides simple methods to read and write them. Each SharedPreferences file is managed by the framework and can be private or shared. This page shows you how to use the SharedPreferences APIs to store and retrieve simple values.
android.accounts.AccountManager. This class provides access to a centralized registry of the user's online accounts. The user enters credentials (username and password) once per account, granting applications access to online resources with "one-click" approval.
Using an AccountManager to store credentials is a much secure way than storing in a file or a SQL DB. A file can be retrieved by any other app unlike via AccountManager Android will enforce that only your app will be able to access to the key.
I would recommend you to think about your requirement first. If authentication is like google+, Facebook and Twitter then I would suggest you to use AccountManager
AccountManager: This centralized registry of user's online account. Account Manager is capable of storing the OAuth
token and does the job for all Google Apps in Android.
SharedPreferences:This is for storing and retrieving small range of data for more this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With