Search code examples
androidhttpauthenticationsharedpreferencesaccountmanager

Accountmanager vs sharedpreference for authentication and server communication


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.


Solution

  • 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.