SharedPreferences getString - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SharedPreferences getString method.

This code example shows how to use the following methods:getString
		return sharedPrefs.getFloat(key, defValue);
	} 
 
	@Override 
	public String getString (String key, String defValue) {
		return sharedPrefs.getString(key, defValue);
	} 
 
	@Override 
	public Map<String, ?> get () {
		return sharedPrefs.getAll();
	} 
 
	@Override 
	public boolean contains (String key) {
		return sharedPrefs.contains(key);
	} 
 
	@Override 
	public void clear () { 
7
CodeRank
This code example shows how to use the following methods:getString
    Log.i(TAG, "onTerminated");
  } 
 
  public synchronized Twitter getTwitter() { // <5> 
    if (this.twitter == null) {
      String username = this.prefs.getString("username", null);
      String password = this.prefs.getString("password", null);
      String apiRoot = prefs.getString("apiRoot",
          "http://yamba.marakana.com/api"); 
      if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(password)
          && !TextUtils.isEmpty(apiRoot)) {
        this.twitter = new Twitter(username, password);
        this.twitter.setAPIRootUrl(apiRoot);
      } 
    } 
    return this.twitter;
  } 
 
  public synchronized void onSharedPreferenceChanged( 
      SharedPreferences sharedPreferences, String key) { // <6>
7
CodeRank
This code example shows how to use the following methods:getString
    Log.i(TAG, "onTerminated");
  } 
 
  public synchronized Twitter getTwitter() { // <5> 
    if (this.twitter == null) {
      String username = this.prefs.getString("username", "");
      String password = this.prefs.getString("password", "");
      String apiRoot = prefs.getString("apiRoot",
          "http://yamba.marakana.com/api"); 
      if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(password)
          && !TextUtils.isEmpty(apiRoot)) {
        this.twitter = new Twitter(username, password);
        this.twitter.setAPIRootUrl(apiRoot);
      } 
    } 
    return this.twitter;
  } 
 
  public synchronized void onSharedPreferenceChanged( 
      SharedPreferences sharedPreferences, String key) { // <6>
7
CodeRank
This code example shows how to use the following methods:getString
			public void onClick(View v) {
				//Recuperamos las preferencias 
				SharedPreferences prefs =
					     getSharedPreferences("MisPreferencias", Context.MODE_PRIVATE);
				 
				String correo = prefs.getString("email", "por_defecto@email.com");
				String nombre = prefs.getString("nombre", "nombre_por_defecto");
				String otra = prefs.getString("otra", "otra_por_defecto");
				 
				Log.i("Preferences", "Correo: " + correo);
				Log.i("Preferences", "Nombre: " + nombre);
				Log.i("Preferences", "Otra: " + otra);
			} 
		}); 
	} 
 
	@Override 
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present. 
		getMenuInflater().inflate(R.menu.main, menu);
7
CodeRank
This code example shows how to use the following methods:getBoolean, getString
		updateSickBeard(); 
	} 
	 
	public String getHost()
	{ 
		return pref.getString("host", "192.168.0.1");
	} 
	 
	public String getPort()
	{ 
		return pref.getString("port", "8081");
	} 
	 
	public String getAPI()
	{ 
		return pref.getString("api", "");
	} 
	 
	public boolean getHTTPS() 
	{ 

7
CodeRank
This code example shows how to use the following methods:getString
  } 
 
  // Returns the Twitter object 
  public synchronized Twitter getTwitter() { 
    if (this.twitter == null) {
      String username = this.prefs.getString("username", null);
      String password = this.prefs.getString("password", null);
      String apiRoot = prefs.getString("apiRoot",
          "http://yamba.marakana.com/api"); 
      if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(password)
          && !TextUtils.isEmpty(apiRoot)) {
        this.twitter = new Twitter(username, password);
        this.twitter.setAPIRootUrl(apiRoot);
      } 
    } 
    return this.twitter;
  } 
 
  // Part of being OnSharedPreferenceChangeListener 
  public synchronized void onSharedPreferenceChanged( 
7
CodeRank
This code example shows how to use the following methods:getString
		return(super.onOptionsItemSelected(item));
	} 
	 
	synchronized private Twitter getClient() { 
		if (client==null) {
			client=new Twitter(prefs.getString("user", ""),
													prefs.getString("password", ""));
			client.setAPIRootUrl("https://identi.ca/api");
		} 
		 
		return(client);
	} 
	 
	synchronized private void resetClient() { 
		client=null;
	} 
	 
	private void updateStatus() { 
		try { 
			getClient().updateStatus(status.getText().toString());
7
CodeRank
This code example shows how to use the following methods:getString
     */ 
    public static String getRegistrationId(Context context) {
        final SharedPreferences prefs = context.getSharedPreferences(
                PREFERENCE,
                Context.MODE_PRIVATE);
        String registrationId = prefs.getString("dm_registration", "");
        return registrationId;
    } 
 
    public static long getLastRegistrationChange(Context context) {
        final SharedPreferences prefs = context.getSharedPreferences(
                PREFERENCE,
                Context.MODE_PRIVATE);
        return prefs.getLong(LAST_REGISTRATION_CHANGE, 0);
    } 
     
    static long getBackoff(Context context) {
        final SharedPreferences prefs = context.getSharedPreferences(
                PREFERENCE,
                Context.MODE_PRIVATE);
7
CodeRank
This code example shows how to use the following methods:getString
      throw new RuntimeException("Unable to load consumer keys from oauth.properties", e);
    } 
  } 
 
  public String[] getTwitPicCredentials() {
    return new String[]{prefs.getString(TWITPIC_USERNAME, null), prefs.getString(TWITPIC_PASSWORD, null)};
  } 
   
  public void saveTwitPicCredentials(String username, String password) {
    Editor editor = prefs.edit();
    editor.putString(TWITPIC_USERNAME, username);
    editor.putString(TWITPIC_PASSWORD, password);
    editor.commit();
  } 
 
} 
7
CodeRank
This code example shows how to use the following methods:edit, getLong, getString
 
    private String getIDFromFile(Context ctx) {
        SharedPreferences mSettings = null;
        mSettings = getPreferenceFile();
        mLogging.info(LOGTAG, "Verifying Install Info");
        mUniqueID = mSettings.getString(UNIQUE_KEYID, "");
        if (mUniqueID.length() == 0) {
            // Application First run 
            mLogging.info(LOGTAG,
                    "First Time Running - Generating Unique Install ID"); 
            mIsFirstTimeRunnig = true;
            mIsAValidInstall = true;
            mUniqueID = UUID.randomUUID().toString();
            mInstallTimeStamp = System.currentTimeMillis();
            mTimeStampHash=DigestUtils.shaHex(mUniqueID + Long.toString(mInstallTimeStamp));
            saveToPreferencesFile(mSettings, mUniqueID, mInstallTimeStamp, mTimeStampHash);
            mLogging.info(LOGTAG, "Install Info Saved with Success");
            return mUniqueID;
        } else { 
            mLogging.info(LOGTAG, "Not First Time Running - Validating Install");

6
CodeRank

Related SharedPreferences getString Questions & Answers:

Other SharedPreferences getString Examples

276:					
277:					// Access Token 
278:					String access_token = mSharedPreferences.getString(PREF_KEY_OAUTH_TOKEN, "");
279:					// Access Token Secret
280:					String access_token_secret = mSharedPreferences.getString(PREF_KEY_OAUTH_SECRET, "");
-
278:					String access_token = mSharedPreferences.getString(PREF_KEY_OAUTH_TOKEN, "");
279:					// Access Token Secret
280:					String access_token_secret = mSharedPreferences.getString(PREF_KEY_OAUTH_SECRET, "");
281:					
282:					AccessToken accessToken = new AccessToken(access_token, access_token_secret);

Read More

86:			HashMap<String, String> user = new HashMap<String, String>();
87:			// user name
88:			user.put(KEY_NAME, pref.getString(KEY_NAME, null));
89:			
90:			// user email id
-
89:			
90:			// user email id
91:			user.put(KEY_EMAIL, pref.getString(KEY_EMAIL, null));
92:			
93:			// return user

Read More

getString Method Overview
Retrieve a String value from the preferences.
See Code Examples for other Android SharedPreferences Methods: