Accountmanager vs sharedpreference for authentication and server communication

In my project, you want to read and write data on the server, it depends on the authentication key (user).

So far, I have planned to use general preferences for storing a user authentication key for further communication with the server.

Later I learned the "Account manager" by reading this tutorial :

I have little confusion about using Account Manager or sharedpreference.

I find it hard to understand how accountmanager works.

Can anyone please indicate which method is suitable for my project.

Any tutorial for an account manager.

Any other suggestions ...?

Thanks in advance.

+5
source share
2 answers

I would advise you to think about your requirement first. If authentication is similar to Google +, Facebook and Twitter, I suggest you use AccountManager

AccountManager . This centralized registry of user accounts. The account manager is able to store the OAuth token and does the job for all Google Apps on Android.

SharedPreferences . This is for storing and retrieving a small range of data for more of this .

+4
source

You can use the Shared Preference. Its easy and effective. Read the documentation for general preferences. Presumably, I used it in many applications, and it is really convenient.

0
source

Source: https://habr.com/ru/post/1204798/


All Articles