Get reference from SharedPreferences : SHA « Security « Android






Get reference from SharedPreferences

 
import android.content.SharedPreferences;

class Main {

  public static Long getLongPref(SharedPreferences prefs, String key,
      long defaultValue) {
    String v = prefs.getString(key, String.valueOf(defaultValue));
    if (v != null) {
      try {
        return Long.parseLong(v);
      } catch (NumberFormatException e) {

      }
    }
    return defaultValue;
  }
}

   
  








Related examples in the same category

1.SHA-1 string
2.hmac Sha1 Digest
3.Sha1 hashes based on a given String
4.SHA1 Utils
5.Using SharedPreferences to store password
6.Using SharedPreferences
7.Drawing Shapes
8.Animated wallpaper draws a rotating wireframe shape with a choice of 2 shapes
9.Animation: shake
10.Glutes shape
11.Reshaping Arabic Sentences and Text Utilities to deal with Arabic
12.Save SharedPreferences
13.Save value to SharedPreferences
14.SharedPreferences Set and get value
15.Compute the SHA-1 hash of the given byte array
16.compute SHA-1 Hash