android - How store credential from OAuth2 in shared preferences -


i have several activities connect google, want connect google once , share credential throughout app. have activity authenticates google via oauth2. returns credential follows:

private googleaccountcredential credential;  ...  credential = googleaccountcredential.usingoauth2(this, drivescopes.drive); 

is there way put shared preferences. i've tried obvious types, i.e. parcelable, etc. , i've found credential can put shared preferences, can't find getter convert googleaccountcredential. had tried making object, again issues getter converting googleaccountcredential type.

if share preference isn't capable, there alternative?

thanks in advance time , help.

you might want use accountmanager api in android. account manager capable of storing oauth token , job google apps in android. may follow blog here.


Comments