If they only perform queries on it? Something like:
private SQLiteDatabase db;
@Override
public void onCreate(Bundle savedInstanceState) {
db = getWritableDatabse();
}
private Task1 extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... arg0) {
db.query(doSomething);
...
}
}
private Task2 extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... arg0) {
db.query(doSomething);
...
}
}
All of your threads in your application should use the same database object — even if reading and writing simultaneously. SQLite handles this with internal locking mechanisms appropriately.
What you don’t want to do is to use multiple database objects to read and write from a database. That may result in inconsistent data.
See here:
The last link is a good one. To quote Kevin Galligan:
As an aside, Kevin has done a good bit of the work of the Android side of ORMLite, my Java ORM package that supports Android.