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

  • Home
  • SEARCH
  • 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 6232613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:08:48+00:00 2026-05-24T10:08:48+00:00

there are similar questions but not clear answer around using sqlite db from multiple

  • 0

there are similar questions but not clear answer around using sqlite db from multiple threads.
Consider the following scenario:

class MainActivity extends Activity {
DbHelper db; //extends sqliteopenhelper
...
void M1() {
    db.getReadableDatabase();
    Cursor c = db.query("...."
    ...
    db.close();
}

void M1() {
    db.getReadableDatabase();
    Cursor c = db.query("...."
    ...
    db.close();
}

ok, this is not multi-thread but question is that,

  1. does it become a problem to use the same instance of sqliteopenhelper instance (i.e. db) like above, opening and closing in many times in different methods?

    And my scenario is the following:

    myAsync extends AsyncTask
    doInBackground(.. {
    do something using M1(); //this is a background thread }} onResume()...{ myAsync.execute(); M2(); //this is the main thread ... }
  2. if you see that in the async scenario, it is probably that two method can access the same database at the same time(for reading only- how about writing?). But they are using the same instance of SqliteOpenHelper. Would it cause to collision and if so how to avoid this?

  3. I would like to learn more about sqlite database and concurrency
    Any ideas would be greatfully appreciated.

  • 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-24T10:08:49+00:00Added an answer on May 24, 2026 at 10:08 am

    ya there is a chance of not collision but your db may close when another thread is aquired, you can go for “Synchronized” concept of thread ie priority and etc when we use synchronized keyword then, one thread completes it task then other thread will starts

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

Sidebar

Related Questions

There are a couple of questions similar to this on stack overflow but not
There are similar question, but not regarding C# libraries I can use in my
I realise there might be similar questions but I couldn't find one that was
There are similar questions, but none answers what I really need. I actually don't
There are similar questions to this, but I don't think anyone has asked this
I realize there are similar questions on this topic, but I still cannot find
There are many similar questions, but apparently no perfect match, that's why I'm asking.
There are a lot of similar questions, but, probably, mine is a little bit
There have been some similar questions asked regarding Grid views, but none have been
I know there have been some similar questions to this, but they haven't helped

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.