tags:

views:

111

answers:

1

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 asynctask.

A: 

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.

kosokund