Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; public class Main { private static final String SP_NAME = "login_data"; public static void setIcon(Context context, String headIcon) { SharedPreferences sp = getSP(context); SharedPreferences.Editor editor = sp.edit(); editor.putString("icon", headIcon); editor.apply(); } private static SharedPreferences getSP(Context context) { return context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); } }