Android SharedPreferences 사용하기
import android.content.SharedPreferences;
private static SharedPreferences mSharedPref;
private static SharedPreferences.Editor mEditor;
private static final String PREF_PDCUI = "PdcUIPrefs" ;
Override
protected void onCreate(Bundle savedInstanceState) {
mSharedPref = getSharedPreferences(PREF_PDCUI, Context.MODE_PRIVATE);
if ( mSharedPref != null )
mEditor = mSharedPref.edit();
}
---------------------------------------------------------------------
1. Write Data to Preferneces
mEditor.putInt(PREF_OPSWIDGET, ((arg1==true)?1:0));
mEditor.commit();
2. Read Data from Preferences
mOpsWidgetShow = mSharedPref.getBoolean(PREF_OPSWIDGET, true);
댓글 없음:
댓글 쓰기