Example usage for android.content Context MODE_PRIVATE

List of usage examples for android.content Context MODE_PRIVATE

Introduction

In this page you can find the example usage for android.content Context MODE_PRIVATE.

Prototype

int MODE_PRIVATE

To view the source code for android.content Context MODE_PRIVATE.

Click Source Link

Document

File creation mode: the default mode, where the created file can only be accessed by the calling application (or all applications sharing the same user ID).

Usage

From source file:Main.java

public static String getString(Context context, String txt, String key) {
    SharedPreferences sp = context.getSharedPreferences(txt, Context.MODE_PRIVATE);
    return sp.getString(key, "");
}

From source file:Main.java

public static Boolean IsFirstLogin(Context context) {
    SharedPreferences preferences = context.getSharedPreferences("FirstLogin", Context.MODE_PRIVATE);
    return preferences.getBoolean("Isfirst", false);
}

From source file:Main.java

public static void putInt(Context context, String key, int value) {
    SharedPreferences sp = context.getSharedPreferences(key, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.putInt(key, value);//w w  w .ja v a2 s  .co m
    editor.apply();
}

From source file:Main.java

public static String readLastAddress(Context context) {
    SharedPreferences sharedPreferences = context.getSharedPreferences("jomoo", Context.MODE_PRIVATE);
    return sharedPreferences.getString("last_address", "");
}

From source file:Main.java

public static int getDeskEffect(Context context) {
    SharedPreferences preferences = context.getSharedPreferences("DeskEffect", Context.MODE_PRIVATE);
    int effect = preferences.getInt("DeskEffectItem", 0);
    return effect;
}

From source file:Main.java

public static String getFromSp(Context ctx, String spName, String key) {
    SharedPreferences sp = ctx.getSharedPreferences(spName, Context.MODE_PRIVATE);
    return sp.getString(key, null);
}

From source file:Main.java

public static void saveWIFIOnly(Context context, boolean isChecked) {
    SharedPreferences sp = context.getSharedPreferences("setting", Context.MODE_PRIVATE);
    sp.edit().putBoolean("isWIFIOnly", isChecked).commit();
}

From source file:Main.java

public static void saveIp(Context context, String Ipname) {
    SharedPreferences preferences = context.getSharedPreferences("IP", Context.MODE_PRIVATE);
    SharedPreferences.Editor edit = preferences.edit();
    edit.putString("ip", Ipname);
    edit.commit();//from  w w w .j a va2s .c o  m
}

From source file:Main.java

public static void putLong(Context context, String key, long value) {
    SharedPreferences sp = context.getSharedPreferences(key, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.putLong(key, value);/*  www  .  ja v  a 2 s .  c om*/
    editor.apply();
}

From source file:Main.java

public static String getString(Context ctx, String key, String defValue) {
    SharedPreferences sp = ctx.getSharedPreferences("config", Context.MODE_PRIVATE);
    return sp.getString(key, defValue);
}