AsyncTask and SQLite Database
What's the best way to access the database through an async task?
I don't think I should pass in a reference to the DbAdapter that the activity is using (could be closed as the activity may be garbage开发者_开发知识库-collected).
Also, the db needs a context to be opened and closed, but I don't have that with the async task.
AsyncTask
is an abstract class, so you have to extend it.
Create a class which extends AsyncTask
, then in the constructor of this class you can add every things you want like the Context
.
精彩评论