Update Shared Preferences From Asynctask Onpostexecute
AsyncTask onPostExecute crashes (reports nullpointerexecption) when I try to use the value I received from doInBackground to update SharedPreferences. My handle to the calling acti
Solution 1:
So problem is most likely related to Context that is assigned to NULL
. I suggest you pass Context variable via constructor of AsyncTask e.q
private Context c;
publicMyTask(Context c){
this.c = c;
}
And call it like:
new MyTask(YourCallerActivity.this).execute();
Note: I recently worked on similar issue(saving SharedPreferences in onPostExecute) and everything worked fine since i passed Context via constructor.
Post a Comment for "Update Shared Preferences From Asynctask Onpostexecute"