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 7733711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:04:19+00:00 2026-06-01T07:04:19+00:00

I have a similar question as here: Is it possible to use ContentProvider and

  • 0

I have a similar question as here: Is it possible to use ContentProvider and direct data access to Database in Android? but in my case I want the widget application to be a separate application.

So I have a first Android application that is using a sqlite database using standard SQLiteOpenHelper. this helper is a singleton that is created in my Application onCreate. Works good.

Now I want to make a second application -so a widget application- that needs to access the database as well. So I would like to use a ContentProvider for that.

1) is it safe to do such way or do I have to refactor the main application to use only ContentProvider (clearly would be a showstopper for me!!)

2) if it is ok, how should I design the contentProvider? I guess I will have to reuse my singleton SQLiteOpenHelper and eventually create it in contentProvider.onCreate?

  • 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-06-01T07:04:21+00:00Added an answer on June 1, 2026 at 7:04 am

    I am also trying to use a ContentProvider and a singleton db object. This appears to be a valid approach.

    Quoting from: http://groups.google.com/group/android-developers/browse_thread/thread/20d8cbf7bf88f6d9

    “Only open the database once. If you are not using a content
    provider, implement a singleton that takes care of opening the
    database once for all code in your app.

    “And let me be clear — there is NOTHING wrong with the content
    provider never closing the database. Nothing. That is NO reason to
    avoid using a content provider. In fact it is a very good design
    approach, and if you aren’t using a content provider but directly
    accessing, I would recommend using the exact same approach for the
    singleton implementation.

    “If you want to have a content provider AND also elsewhere do direct
    access to the database, then implement your content provider on top of
    the singleton that owns the database.

    — Dianne Hackborn Android framework engineer hack…@android.com

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

Sidebar

Related Questions

There is a similar question here on SO, but I have a fairly small
There was a similar question asked here three years ago, but I want to
I have seen similar questions here but I just can't understand them. I am
There are other questions on here that sound similar but are not. I have
I have a similar question than django cross-site reverse . But i think I
I have checked this similar question, but the suggestions did not solve my problem:
I asked a similar question here a while back but all the answers were
Here is what I want to do. Use this HTML line and have the
Referring on this question , I have a similar -but not the same- problem..
I have a question similar to this but in the context of L2S. I

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.