Android Open Source - cheepcheep Preferences Provider






From Project

Back to project page cheepcheep.

License

The source code is released under:

Apache License

If you think the Android project cheepcheep listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.tarrio.cheepcheep.service;
/*w  w  w.j a v  a 2 s . co  m*/
import org.tarrio.cheepcheep.model.Preferences;

import android.content.Context;
import android.content.SharedPreferences;

public class PreferencesProvider {

  public static final String PREF_NAME = "CheepCheep";

  private Context context;

  public PreferencesProvider(Context context) {
    this.context = context;
  }

  /**
   * Retrieves the current user preferences.
   * 
   * @return an object containing the current preferences.
   */
  public Preferences get() {
    SharedPreferences sp = context.getSharedPreferences(PREF_NAME,
        Context.MODE_PRIVATE);
    Preferences prefs = new Preferences();
    prefs.setUsername(sp.getString("username", ""));
    prefs.setConsumerToken(sp.getString("consumerToken", ""));
    prefs.setConsumerSecret(sp.getString("consumerSecret", ""));
    return prefs;
  }

  /**
   * Saves the given preferences.
   * 
   * @param prefs
   *            the object containing the preferences to save.
   */
  public void save(Preferences prefs) {
    SharedPreferences sp = context.getSharedPreferences(PREF_NAME,
        Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.putString("username", prefs.getUsername());
    editor.putString("consumerToken", prefs.getConsumerToken());
    editor.putString("consumerSecret", prefs.getConsumerSecret());
    editor.commit();
  }

}




Java Source Code List

org.tarrio.cheepcheep.Constants.java
org.tarrio.cheepcheep.HomeTimelineActivity.java
org.tarrio.cheepcheep.OAuthActivity.java
org.tarrio.cheepcheep.SingleTweetActivity.java
org.tarrio.cheepcheep.TweetListActions.java
org.tarrio.cheepcheep.TweetListAdapter.java
org.tarrio.cheepcheep.UserInfoActivity.java
org.tarrio.cheepcheep.dialog.CheepCheepDialog.java
org.tarrio.cheepcheep.dialog.ConfirmDeleteTweetDialog.java
org.tarrio.cheepcheep.dialog.NewTweetDialog.java
org.tarrio.cheepcheep.exceptions.AuthError.java
org.tarrio.cheepcheep.exceptions.CheepCheepException.java
org.tarrio.cheepcheep.exceptions.NetError.java
org.tarrio.cheepcheep.exceptions.ParseError.java
org.tarrio.cheepcheep.exceptions.TweetNotFoundError.java
org.tarrio.cheepcheep.exceptions.UserNotFoundError.java
org.tarrio.cheepcheep.http.HttpClientFactory.java
org.tarrio.cheepcheep.http.OAuthHttpClient.java
org.tarrio.cheepcheep.model.Preferences.java
org.tarrio.cheepcheep.model.Tweet.java
org.tarrio.cheepcheep.model.User.java
org.tarrio.cheepcheep.service.PreferencesProvider.java
org.tarrio.cheepcheep.service.TwitterJSONSerializer.java
org.tarrio.cheepcheep.service.TwitterService.java
org.tarrio.cheepcheep.service.TwitterStatusSaverService.java
org.tarrio.cheepcheep.task.AsyncTwitterTask.java
org.tarrio.cheepcheep.task.CreateNewTweetTask.java
org.tarrio.cheepcheep.task.DeleteTweetTask.java
org.tarrio.cheepcheep.task.FollowUnfollowUserTask.java
org.tarrio.cheepcheep.task.GetSingleTweetTask.java
org.tarrio.cheepcheep.task.GetUserInfoTask.java
org.tarrio.cheepcheep.task.TaskCallback.java
org.tarrio.cheepcheep.task.UpdateTweetsTask.java
org.tarrio.cheepcheep.task.VerifyCredentialsTask.java