Skip to content Skip to sidebar Skip to footer

How To Store And Access Radio Buttons From Shared Preferences?

There are a lot of questions on SO about saving radio buttons state in Shared Preferences but none of them provide the solution that I'm looking for. I'm creating 15 radio groups a

Solution 1:

public void loadArray(String arrayName, Context mContext) {
    SharedPreferences prefs = mContext.getSharedPreferences("preferencename", 0);
    int size = prefs.getInt(arrayName + "_size", 0);
    int array[] = new int[size];
    for(int i=0;i<size;i++) {
        array[i] = prefs.getInt(arrayName + "_" + i, 0);
//->put Toast here and check whether your are getting the id's or not. If you
//->are getting it, return arrays of id back to calling method
    }
}

Post a Comment for "How To Store And Access Radio Buttons From Shared Preferences?"