When you are initializing your Db
object using getApplicationContext()
in the following line...its not getting any Context
...
Db h = new Db(getApplicationContext());
To solve your Context
problem you can pass the context of your activity through the AsyncTask()
constructor. I'm giving you a scenario...
Suppose, from MainActivity.java
you are executing your ProgressTask.java
then you should pass the Context
as follows....
new ProgressTask(MainActivity.this).execute();
In your ProgressTask.java
class, you can retrieve that Context
from ProgressTask()
contructor as follows....
public ProgressTask extends AsyncTask<String, String, JSONObject> {
Context mContext;
ProgressTask (Context context) {
mContext.this = context
}
@Override
protected void onPreExecute()
{
super.onPreExecute();
}
.........
}
Now, you can initialize your Db
object as follows...
Db h = new Db(mContext);
This will solve your problem.