2010년 11월 1일 월요일

[Android] How to use SharedPreferences ?

private static final boolean INIT_TOOLBAR = true;
private static boolean mToolbar = INIT_TOOLBAR;


void restorePreference() {
    SharedPreferences pref = getPreferences(Activity.MODE_PRIVATE);


    mToolbar = pref.getBoolean("PREF_TOOLBAR", INIT_TOOLBAR);
}


void savePreferrence() {
    SharedPreferences pref = getPreferences(Activity.MODE_PRIVATE);
    SharedPreferences.Editor editor = pref.edit();


    editor.putBoolean("PREF_TOOLBAR", mToolbar);

    editor.commit();
}

댓글 없음:

댓글 쓰기