Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.content.SharedPreferences; import android.util.Log; public class Main { private static String facebookUserName; public static String getFacebookUserName(Context context) { if (facebookUserName != null) return facebookUserName; else { SharedPreferences prefs = context.getSharedPreferences("profilo", Context.MODE_PRIVATE); String name = prefs.getString("reg_username", ""); if (name.isEmpty()) { Log.e("HELPER_FACEBOOK", "username facebook not found."); return null; } else { facebookUserName = name; return facebookUserName; } } } }