Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.content.SharedPreferences; public class Main { private static final String PREF_FILE_KEY = "be.scuad.nmct.be.scuad.PREFERENCE_FILE_KEY"; private static final String PREF_ACTIVE_ACCOUNT = "active_account"; public static boolean setActiveAccount(final Context context, final String accountName) { SharedPreferences sp = getSharedPreferences(context); sp.edit().putString(PREF_ACTIVE_ACCOUNT, accountName).apply(); return true; } private static SharedPreferences getSharedPreferences(final Context context) { return context.getSharedPreferences(PREF_FILE_KEY, Context.MODE_PRIVATE); } }