I’m making an application that get data from webservice, insert it into a database and show the data into a tablelayout.
So what I want to do is that in a X lapse of time, REFRESH the table with the content of webservice.
I can do that with the onResume method, but it isn’t what I want.
I was reading about asynctask, so the task of using webservice and inserting data into sqlite could be in a second thread.
In the method doInBackground I start the webservice and insert information into a sqlite, and in the onPostExecute I put the information dynamically into a table.
My problem is that, when I initialize the database to read it, I put:
UsuariosSQLiteHelper usdbh = new UsuariosSQLiteHelper(this, "DBIncidentes", null, 1);
and in THIS, there is a context problem.
This happened too in the part of refreshing data into the table (in onPostExecute), because all the time I put THIS like creating a textview, there is a context problem.
I basically know about context, I read that I have to create a constructor of the asynctask class and initialize a context, and I can change THIS for the context of the constructor.
I’m a bit lost in this part, anyone can help me?
In this case
thisrefers to your ASyncTask and not your Activity. You need to useActivityName.thisinstead.