Accountmanager vs sharedpreference for authentication and server communication
Asked Answered
L

2

8

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.

Lyssa answered 16/10, 2014 at 6:26 Comment(0)
P
6

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.

Participate answered 16/10, 2014 at 6:56 Comment(4)
Though I am using Private account for user only for this application. Shared preferences is an solution.Lyssa
r u using any auth token? What happen if user changes password on another client? If u need to manage this all then U should user Account Manager else SharedPreferences is goodParticipate
The answer above seems not matching https://mcmap.net/q/620907/-should-you-use-accountmanager-for-storing-usernames-and-passwords-for-an-android-app, which discourage one to use AccountManager unless one need syncAdapterFireresistant
@Fireresistant this answer for the above question. I don't know the context which you are talking about.Participate
L
0

You could use Shared Preference. Its easy and effective as well. Read the documentation to know about Shared Preference. Presonally I have used it in many application and it comes really handy.

Longmire answered 16/10, 2014 at 6:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.