SharedPreferences Set and get value : SHA « Security « Android






SharedPreferences Set and get value

 
//package shoozhoo.libandrotranslation;

import java.io.Closeable;
import java.util.Locale;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.util.Log;

class LibAndTransUtil {
  private static String KEY_APPTRANSLATION = "KEY_APPTRANSLATION";
  private static String KEY_LANG = "KEY_LANG";
  public static String getTranslationLang(Context ctx){
    SharedPreferences pref = ctx.getSharedPreferences(KEY_APPTRANSLATION, Context.MODE_PRIVATE);
    if(pref==null){
      return "";
    }
    return pref.getString(KEY_LANG, Locale.getDefault().getLanguage());
  }
  public static void saveTranslationLang(Context ctx, String lang){
    SharedPreferences pref = ctx.getSharedPreferences(KEY_APPTRANSLATION, Context.MODE_PRIVATE);
    Editor editor = pref.edit();
    editor.putString(KEY_LANG, lang);
    editor.commit();
  }
}

   
  








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.Get reference from SharedPreferences
11.Glutes shape
12.Reshaping Arabic Sentences and Text Utilities to deal with Arabic
13.Save SharedPreferences
14.Save value to SharedPreferences
15.Compute the SHA-1 hash of the given byte array
16.compute SHA-1 Hash