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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:43:47+00:00 2026-05-21T12:43:47+00:00

Within my app I’m in the process of wrapping the database access into a

  • 0

Within my app I’m in the process of wrapping the database access into a ContentProvider. This because occasionally I have crashes because two threads access the database at the same time. I rely heavily on background threads to pull down data from a web server and put that in the database; when the user switches between activities you may have multiple of those running at the same time. That’s the why.

Now the how.
I’ve implemented the ContentProvider class, and that seems to work fine. Registered in the manifest, and this also shows up in LogCat that the provider is active.

The app, with all its activities, accesses the database through a wrapper class which itself is not an activity. The constructor of this class takes the context of the calling activity as parameter. Nothing special there.

Now my problem:
When accessing the content provider through the context.query() method, I get a crash:

04-15 23:05:33.699: ERROR/AndroidRuntime(3564): Caused by: java.lang.NullPointerException
04-15 23:05:33.699: ERROR/AndroidRuntime(3564):     at android.content.ContentResolver.acquireProvider(ContentResolver.java:727)
04-15 23:05:33.699: ERROR/AndroidRuntime(3564):     at android.content.ContentResolver.query(ContentResolver.java:239)
04-15 23:05:33.699: ERROR/AndroidRuntime(3564):     at squirrel.DeaddropDroid.DeaddropDB.query(DeaddropDB.java:482)

The offending line is:

final Cursor blog2 = db.query(DeaddropDB.BLOG_TABLE, new String[] {
            DeaddropDB.KEY_ID, DeaddropDB.KEY_DATE,
            DeaddropDB.KEY_BLOG_SUMMARY }, null, null,
            DeaddropDB.KEY_DATE + " DESC");

db is a DB object, the constructor takes the activity’s context as parameter.
In the same activity, the following line works as expected and gives the correct results:

final Cursor blog = managedQuery(DeaddropDBProvider.BLOG_URI,
            new String[] {DeaddropDB.KEY_ID, DeaddropDB.KEY_DATE,
            DeaddropDB.KEY_BLOG_SUMMARY }, null, null,
            DeaddropDB.KEY_DATE + " DESC");

This proves that my ContentProvider works and is registered properly. I’m really at a loss on what’s going on here! Why does this query not work as advertised?

  • 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-21T12:43:48+00:00Added an answer on May 21, 2026 at 12:43 pm

    And finally, as promised, my answer.

    Right, so it was my fault after all (of course). Took some digging in Android’s sources (another thumbs-up for open sources), and with some further testing I found the reason. My Uri was null! I try to import the uri from the provider but there something goes wrong.
    That’s going to be my next question, as while I have the workaround, I don’t understand why it goes wrong.

    That’s my next question: Load URI from myContentProvider fails (null result), as while I have a working solution, I don’t understand why it goes wrong. Further details on the issue are over there.

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

Sidebar

Related Questions

I have custom classes that I currently instantiate within App.xaml as resources. I want
within my App it should be forbidden to edit (customize) the TabBar. This means
I have other pages within my app preferences which are stored as separate files
How do I manipulate textfield variables within an iPhone app? I want to have
I would like to do two things within my Android app : Check if
I want to send an App link within the App like this: http://itunes.apple.com/app/myiphoenapp/id373185673 The
I have a console app, myapp.exe. Within the app is a function, let's call
I have a 400 pattern images at 400x300 bundled within my app. I would
I have a Button within my app whose enabledness I have bound to whether
The content within the app is being updated using XHR. This involves changing the

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.