link of image into object or string or anything that can be stored into
SharedPreferences
Im new to android and java programming, please explain in detail what
should i do from here. I want to download an image and store it in a
SharedPreferences. any variable will do, as long as you can also show me
how to output the image as imageview. i read similar topics but i cant
understand fully and i don't know how to work with those.
here's my code, class extends AsyncTask -> onPreExecute:
protected void onPostExecute(String result) {
SharedPreferences pref = getApplicationContext().getSharedPreferences(
"athan", MODE_PRIVATE);
Editor editor = pref.edit();
try{
JSONArray jArray = new JSONArray(result);
for(int i=0;i<jArray.length();i++)
{
JSONObject json_data = jArray.getJSONObject(i);
editor.putString("fstime"+i, json_data.getString("time"));
editor.putString("fspname"+i,
json_data.getString("postname"));
//this is what i want to modify:
//editor.putString("fsfile"+i, json_data.getString("file"));
//"json_data.getString("file")" gives a value of
string of link to the image
//so instead of saving the link, i want to download
the image and store in in SharedPreference instead.
//like editor.putImage("fsfile"+i,
json_data.getImage("file"));
}
editor.putBoolean("fileshares", true);
editor.commit();
}
catch(JSONException e)
{
Log.e("Athan", "Error parsing data "+e.toString());
}
fileshareview();
}
}
No comments:
Post a Comment