So instead of creating a database, I\'m storing the data using SharedPreference
.
My code is below:
SharedPreferences.Editor editor =
Do you use shared preferences in two different activieties of one app ?
Also try to specify preferences name, or use some Manager to handle all preferences, all this explained here
editor.putInt("favid"+id, 1);
what's about id is equals to 0? here you are reading starting from 1
for (int i = 1; i < 19; i++) {
See docs about getPrefernces
method:
Retrieve a SharedPreferences object for accessing preferences that are private to this activity.
So, if you want to share preferences between activities you should use getSharedPreferences with specified name.