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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:41:26+00:00 2026-05-23T11:41:26+00:00

I’m having some difficulty debugging a null pointer exception. E/AndroidRuntime( 1760): java.lang.RuntimeException: Unable to

  • 0

I’m having some difficulty debugging a null pointer exception.

E/AndroidRuntime( 1760): java.lang.RuntimeException: Unable to instantiate application edu.lafayette.cs.geology.GeoDatabase: java.lang.NullPointerException

...

E/AndroidRuntime( 1760): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 1760):    at android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:101)
E/AndroidRuntime( 1760):    at android.content.Loader.<init>(Loader.java:85)
E/AndroidRuntime( 1760):    at android.content.AsyncTaskLoader.<init>(AsyncTaskLoader.java:90)
E/AndroidRuntime( 1760):    at android.content.CursorLoader.<init>(CursorLoader.java:113)
E/AndroidRuntime( 1760):    at edu.lafayette.cs.geology.GeoDatabase.createLoader(GeoDatabase.java:123)

Here is the relevant method createLoader in my code.

private CursorLoader createLoader(int id) {
    Uri tableUri;
    String[] projection;

    // Set the URI to query depending on the id of this loader.
    switch (id) {
    case LOCAL_FOLDER_LOADER:
        tableUri = LocalProvider.CONTENT_URI_FOLDER;
        projection = Folder.COLUMNS;
        break;
    case LOCAL_BEDDING_LOADER:
        tableUri = LocalProvider.CONTENT_URI_BEDDING;
        projection = Bedding.COLUMNS;
        break;
    case LOCAL_CONTACT_LOADER:
        tableUri = LocalProvider.CONTENT_URI_CONTACT;
        projection = Contact.COLUMNS;
        break;
    case LOCAL_FAULT_LOADER:
        tableUri = LocalProvider.CONTENT_URI_FAULT;
        projection = Fault.COLUMNS;
        break;
    case LOCAL_JOINT_SET_LOADER:
        tableUri = LocalProvider.CONTENT_URI_JOINT_SET;
        projection = JointSet.COLUMNS;
        break;
    default:
        throw new IllegalArgumentException("Unknown cursor loader id");
    }

    // Load up that cursor loader. Next, onLoadComplete is called.
    Log.d("createLoader", ""+tableUri);
    Log.d("createLoader", ""+projection);
    Log.d("createLoader", ""+this);
    CursorLoader cursorLoader = new CursorLoader(this, tableUri,
            projection, null, null, null);
    Log.d("createLoader", "statement reached");
    cursorLoader.registerListener(id, this);
    return cursorLoader;
}

Line 125 is the one calling the CursorLoader constructor, in between the log statements. The log shows that tableUri, projection, and of course this are not null. The “statement reached” call is never reached. The rest of the nulls in the constructor call are supposed to be there, and they are specified in the API. I can change the constructor call to use string literals and arrays instead of those three nulls, and the same exception is thrown. Anyone know what’s up?

I’d love to check out the CursorLoader source for clues, but Google has not released the source for the classes in API level 12 of this “open source” project.

  • 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-23T11:41:27+00:00Added an answer on May 23, 2026 at 11:41 am

    The problem had nothing to do with CursorLoader, it was that I passed the CursorLoader a reference to this before the constructor finished. The method createLoader was called by a method which was called by a method which was called by the constructor.

    This code is inside a subclass of Application, which as far as I’m aware is bad practice because all I’m using that for is sharing data between activities, where that should be done with Intents and Bundles. So I actually just changed the method header for the constructor to override the onCreate method instead, which was more appropriate, and fixed my issue.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have some data like this: 1 2 3 4 5 9 2 6
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

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.