How to store and retrieve an object from Gson in android?
<p>In my activity, the user has an array of images he picks, and then I want to store them in preferences. Then the user leaves the activity, and comes back, I want those images still loaded into an <strong>ImageView</strong>. I'm trying to use Gson to accomplish this, but am having trouble and can't see what I'm doing wrong. 
Hoping external insight may help me with this obvious answer I'm just not seeing. </p>

<p>Thank you. </p>

<p>Here is my code so far.</p>

<pre><code>private void savePreferencesForImages(String key, ArrayList&lt;Image&gt; imageList)
    {
        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        Gson gson = new Gson();
        String json = gson.toJson(imageList);
        editor.putString(key,json);
        editor.commit();
    }


//Storing Local data.
private void loadPreferences()
{
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    Gson gson = new Gson();
    String gsonString = sharedPreferences.getString("userImages", "");
    ArrayList&lt;Image&gt; images = gson.fromJson(gsonString, Image.class);//Ask StackOverflow tomorrow.
}
</code></pre>