My sharedPreferences is not working.
public static final String PREF_NAME = "TelaApresentacaoActivityPreferences";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_screen_slide);
mPager = (ViewPager) findViewById(R.id.pager);
mPagerAdapter = new ScreenSlidePagerAdapter(getFragmentManager());
mPager.setAdapter(mPagerAdapter);
mPager.setOnPageChangeListener(newViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
invalidateOptionsMenu();
}
});
sharedPreferences = getSharedPreferences(PREF_NAME, MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
}
@Override
protected void onStop() {
super.onStop();
sharedPreferences = getSharedPreferences(PREF_NAME, MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.commit();
}
@Override
protected void onDestroy() {
super.onDestroy();
sharedPreferences = getSharedPreferences(PREF_NAME, MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.clear();
editor.commit();
}
In my AndroidManifest.xml, I put code snippets in
android:onHistory="true"