Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6911687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:59:20+00:00 2026-05-27T08:59:20+00:00

If they only perform queries on it? Something like: private SQLiteDatabase db; @Override public

  • 0

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);
        ...
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:59:21+00:00Added an answer on May 27, 2026 at 8:59 am

    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:

    • Is SQLite threadsafe?
    • Android SQLite Locking details

    The last link is a good one. To quote Kevin Galligan:

    • Sqlite takes care of the file level locking. Many threads can read, one can write. The locks prevent more than one writing.
    • Android implements some java locking in SQLiteDatabase to help keep things straight.
    • If you go crazy and hammer the database from many threads, your database will (or should) not be corrupted.

    Here’s what’s missing. If you try to write to the database from actual distinct connections at the same time, one will fail. It will not wait till the first is done and then write. It will simply not write your change. Worse, if you don’t call the right version of insert/update on the SQLiteDatabase, you won’t get an exception. You’ll just get a message in your LogCat, and that will be it.

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two threads in haskell that perform IO. (They print only). Something like
I'm trying to use some data from a PlanPlusOnline account. They only provide a
I've been reading up on the x86 instruction set extensions, and they only seem
Motorola phones do not have Verisign/Thawte root certificates for code signing. They only embed
Right guys, all autocomplete plugins and functions that I've found, they only update upon
Every page on my application will display 1000 records and they are only needed
i am dynamically creating radio using jquery as shown belown. but they value only
They will also search part of their name. Not only words with spaces. If
I'm curious why only some System.Web.UI.WebControl controls implement certain interfaces when they have the
Should I provide these things by default or only on client request (if they

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.