2

I am using linkedin-j library for authenication

I want to persist the LinkedIn Access token object.

LinkedInOAuthService oAuthService = LinkedInOAuthServiceFactory
    .getInstance()
    .createLinkedInOAuthService(
        LK_CONSUMER_KEY, LK_CONSUMER_SECRET
    );

//Need to persist this accessToken
LinkedInAccessToken accessToken = oAuthService
    .getOAuthAccessToken(liToken, oauthVerifier);
C1pher
  • 1,933
  • 6
  • 33
  • 52
Jambaaz
  • 2,788
  • 1
  • 19
  • 30
  • [Android | Storage Options](http://developer.android.com/guide/topics/data/data-storage.html) – zapl Dec 13 '13 at 18:41

1 Answers1

0

You can use SharedPreferences.

This is an example shown for Facebook. You can implement the same way for for LinkedIn.

When the user has logged in:

Editor editor = context.getSharedPreferences("facebook-session", 
                                             Context.MODE_PRIVATE).edit();
editor.putString("access_token", session.getAccessToken());
editor.putLong("expires_in", session.getAccessExpires());

When you app starts, in onCreate, restore the session if it exists:

SharedPreferences savedSession = context.getSharedPreferences
                                 ("facebook-session",Context.MODE_PRIVATE);
session.setAccessToken(savedSession.getString("access_token", null));
session.setAccessExpires(savedSession.getLong("expires_in", 0));

Source: https://developers.facebook.com/blog/post/640/

Joel Fernandes
  • 4,776
  • 2
  • 26
  • 48