*SAVE ARRAY*

public boolean saveArray(String[] array, String arrayName, Context
mContext) {
    SharedPreferences prefs =
mContext.getSharedPreferences("preferencename", 0);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putInt(arrayName +"_size", array.length);
    for(int i=0;i<array.length;i++)
        editor.putString(arrayName + "_" + i, array[i]);
    return editor.commit();
}


*LOAD ARRAY*

*
*

public String[] loadArray(String arrayName, Context mContext) {
    SharedPreferences prefs =
mContext.getSharedPreferences("preferencename", 0);
    int size = prefs.getInt(arrayName + "_size", 0);
    String array[] = new String[size];
    for(int i=0;i<size;i++)
        array[i] = prefs.getString(arrayName + "_" + i, null);
    return array;
}


Thanks

RK


On Fri, Aug 17, 2012 at 10:39 AM, Sadhna Upadhyay <[email protected]
> wrote:

> HI everybodey,
>     how to store value in array in sheredprefe rence and fetech them in
> anothr activity
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to