sdk/src/com/socialize/api/PreferenceSessionPersister.java
@Override
	public synchronized WritableSession load(Context context) {
		
		SharedPreferences prefs = context.getSharedPreferences(PREFERENCES, Context.MODE_PRIVATE);
		
		String key = prefs.getString("consumer_key", null);
		String secret = prefs.getString("consumer_secret", null);
		
		UserProviderCredentialsMap userProviderCredentials = loadUserProviderCredentials(prefs);
		
		WritableSession session = sessionFactory.create(key, secret, userProviderCredentials);
			
		session.setRestored(true);
		
		String oauth_token = prefs.getString("consumer_token", null);
		String oauth_token_secret = prefs.getString("consumer_token_secret", null);
		
		if(StringUtils.isEmpty(oauth_token) || StringUtils.isEmpty(oauth_token_secret)) {
			return null;
		}

		session.setConsumerToken(oauth_token);
		session.setConsumerTokenSecret(oauth_token_secret);
		
		String userJson = prefs.getString("user", null);
		
		User user = null;
		
		if(userJson != null) {
			try {
				JSONObject json = new JSONObject(userJson);
				user = userFactory.fromJSON(json);
				session.setUser(user);
			}
			catch (JSONException e) {
				if(logger != null) {
					logger.error("Failed to deserialize user object", e);
				}
				else {
					SocializeLogger.e("Failed to deserialize user object", e);
				}
			}
		}
		
		String userSettingsJson = prefs.getString("user-settings", null);
		
		if(userSettingsJson != null) {
			try {
				JSONObject json = new JSONObject(userSettingsJson);
				UserSettings userSettings = userSettingsFactory.fromJSON(json);
				session.setUserSettings(userSettings);
			}
			catch (JSONException e) {
				if(logger != null) {
					logger.error("Failed to deserialize user settings object", e);
				}
				else {
					SocializeLogger.e("Failed to deserialize user settings object", e);
				}
			}
		}
		else if(user != null) {
			session.setUserSettings(createSettingsLegacy(user));
		}
		
		return session;
	}
@Override
	public synchronized WritableSession load(Context context) {
		
		SharedPreferences prefs = context.getSharedPreferences(PREFERENCES, Context.MODE_PRIVATE);
		
		String key = prefs.getString("consumer_key", null);
		String secret = prefs.getString("consumer_secret", null);
		
		UserProviderCredentialsMap userProviderCredentials = loadUserProviderCredentials(prefs);
		
		WritableSession session = sessionFactory.create(key, secret, userProviderCredentials);
			
		session.setRestored(true);
		
		String oauth_token = prefs.getString("consumer_token", null);
		String oauth_token_secret = prefs.getString("consumer_token_secret", null);
		
		if(StringUtils.isEmpty(oauth_token) || StringUtils.isEmpty(oauth_token_secret)) {
			return null;
		}

		session.setConsumerToken(oauth_token);
		session.setConsumerTokenSecret(oauth_token_secret);
		
		String userJson = prefs.getString("user", null);
		
		User user = null;
		
		if(userJson != null) {
			try {
				JSONObject json = new JSONObject(userJson);
				user = userFactory.fromJSON(json);
				session.setUser(user);
			}
			catch (JSONException e) {
				if(logger != null) {
					logger.error("Failed to deserialize user object", e);
				}
				else {
					SocializeLogger.e("Failed to deserialize user object", e);
				}
			}
		}
		
		String userSettingsJson = prefs.getString("user-settings", null);
		
		if(userSettingsJson != null) {
			try {
				JSONObject json = new JSONObject(userSettingsJson);
				UserSettings userSettings = userSettingsFactory.fromJSON(json);
				session.setUserSettings(userSettings);
			}
			catch (JSONException e) {
				if(logger != null) {
					logger.error("Failed to deserialize user settings object", e);
				}
				else {
					SocializeLogger.e("Failed to deserialize user settings object", e);
				}
			}
		}
		else if(user != null) {
			session.setUserSettings(createSettingsLegacy(user));
		}
		
		return session;
	}
@ Override public synchronized WritableSession load ( Context context ) { SharedPreferences prefs = context . getSharedPreferences ( PREFERENCES , Context . MODE_PRIVATE ) ; String key = prefs . getString ( "consumer_key" , null ) ; String secret = prefs . getString ( "consumer_secret" , null ) ; UserProviderCredentialsMap userProviderCredentials = loadUserProviderCredentials ( prefs ) ; WritableSession session = sessionFactory . create ( key , secret , userProviderCredentials ) ; session . setRestored ( true ) ; String oauth_token = prefs . getString ( "consumer_token" , null ) ; String oauth_token_secret = prefs . getString ( "consumer_token_secret" , null ) ; if ( StringUtils . isEmpty ( oauth_token ) || StringUtils . isEmpty ( oauth_token_secret ) ) { return null ; } session . setConsumerToken ( oauth_token ) ; session . setConsumerTokenSecret ( oauth_token_secret ) ; String userJson = prefs . getString ( "user" , null ) ; User user = null ; if ( userJson != null ) { try { JSONObject json = new JSONObject ( userJson ) ; user = userFactory . fromJSON ( json ) ; session . setUser ( user ) ; } catch ( JSONException e ) { if ( logger != null ) { logger . error ( "Failed to deserialize user object" , e ) ; } else { SocializeLogger . e ( "Failed to deserialize user object" , e ) ; } } } String userSettingsJson = prefs . getString ( "user-settings" , null ) ; if ( userSettingsJson != null ) { try { JSONObject json = new JSONObject ( userSettingsJson ) ; UserSettings userSettings = userSettingsFactory . fromJSON ( json ) ; session . setUserSettings ( userSettings ) ; } catch ( JSONException e ) { if ( logger != null ) { logger . error ( "Failed to deserialize user settings object" , e ) ; } else { SocializeLogger . e ( "Failed to deserialize user settings object" , e ) ; } } } else if ( user != null ) { session . setUserSettings ( createSettingsLegacy ( user ) ) ; } return session ; }
/* (non-Javadoc)
@see com.socialize.api.SocializeSessionPersister#load(android.content.Context)
/ * ( non - Javadoc )