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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:52:02+00:00 2026-05-26T03:52:02+00:00

New to Android and Java really (I’m a Pascal programmer originally) and having a

  • 0

New to Android and Java really (I’m a Pascal programmer originally) and having a problem – my app is force closing and I can’t work out why.

I’m simply trying to call an activity to display a table of data from my (currently empty) database. I’m using the ‘Learning Android’ book and have pretty much cut and pasted most of my code out of that. I’ve refactored all my DB access routines to a specific class but seems to be a problem.

Calling method:

@Override
public void onResume() {
    super.onResume();

    Log.i(TAG, "In onResume...");

    // Link to WYWHApplication module
    WYWHApplication wywh = (WYWHApplication) this.getApplication();

    // Fetch trip list
    Cursor tripList = wywh.getBasicList();

and this is the DB class:

public class WYWHApplication extends Application {

private static final String TAG = WYWHApplication.class.getSimpleName();

@Override
public void onCreate() {
    super.onCreate();
    Log.i(TAG, "In onCreate for app...");
}

@Override
public void onTerminate() {
    super.onTerminate();
    Log.i(TAG, "In onTerminate for app...");
}

// Link to DB class
private DatabaseUtils dbUtils;

// Accessor method - how other modules get access to DB.
public DatabaseUtils getDBData() {
    return dbUtils;
}

public synchronized Cursor getBasicList() {

    Log.i(TAG, "Getting basic list of trips");

    // Get list of DB entries
    Cursor tripEntries = this.getDBData().fetchList("TRIP_TABLE");

    Log.i(TAG, "...returned from getting basic list of trips");

    return tripEntries;
}

The LogCat has the following:

10-14 20:38:29.543: INFO/WYWHApplication(305): In onCreate for app...
10-14 20:38:29.603: DEBUG/WYWH(305): Start of onCreate....
10-14 20:38:30.283: DEBUG/WYWH(305): ...end of onCreate.
10-14 20:41:05.943: INFO/ActivityManager(58): Starting activity: Intent { cmp=co.uk.sanetech.wywh/.TripsScreenActivity }
10-14 20:41:06.183: INFO/Trips(305): Start of onCreate....
10-14 20:41:06.773: INFO/Trips(305): In onResume...
10-14 20:41:06.773: INFO/WYWHApplication(305): Getting basic list of trips
10-14 20:41:06.793: DEBUG/AndroidRuntime(305): Shutting down VM
10-14 20:41:06.793: WARN/dalvikvm(305): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
10-14 20:41:06.993: ERROR/AndroidRuntime(305): FATAL EXCEPTION: main
10-14 20:41:06.993: ERROR/AndroidRuntime(305): java.lang.RuntimeException: Unable to resume activity {co.uk.sanetech.wywh/co.uk.sanetech.wywh.TripsScreenActivity}: java.lang.NullPointerException
10-14 20:41:06.993: ERROR/AndroidRuntime(305):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3128)

(left a bit out here)

10-14 20:41:06.993: ERROR/AndroidRuntime(305): Caused by: java.lang.NullPointerException
10-14 20:41:06.993: ERROR/AndroidRuntime(305):     at co.uk.sanetech.wywh.WYWHApplication.getBasicList(WYWHApplication.java:36)
10-14 20:41:06.993: ERROR/AndroidRuntime(305):     at co.uk.sanetech.wywh.TripsScreenActivity.onResume(TripsScreenActivity.java:42)
10-14 20:41:06.993: ERROR/AndroidRuntime(305):     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
10-14 20:41:06.993: ERROR/AndroidRuntime(305):     at android.app.Activity.performResume(Activity.java:3823)
10-14 20:41:06.993: ERROR/AndroidRuntime(305):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3118)
10-14 20:41:06.993: ERROR/AndroidRuntime(305):     ... 12 more

Code for fetchList:

public Cursor fetchList(String tabName) {

   Log.i(TAG, "In fetchList...");

…as I’m not getting that last debug message, that suggests (to me) that the problem is the call to fetchList but not sure why.

Any help gratefully accepted…

  • 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-26T03:52:03+00:00Added an answer on May 26, 2026 at 3:52 am

    From the code you have posted there, the instance dbUtils is never initialized to anything, so it is null. Hence, when you try to call fetchList(), you are calling the method on an instance that doesn’t exist.

    Your declaration should probably look something like this

    // Link to DB class
    private DatabaseUtils dbUtils = new DatabaseUtils();
    
    // Accessor method - how other modules get access to DB.
    public DatabaseUtils getDBData() {
        return dbUtils;
    }
    

    Where the object is instantiated before you try to access methods on it.

    HTH.

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

Sidebar

Related Questions

I'm pretty new to Android and Java, though I've really been excited about what
Possible Duplicate: Scala on Android: java.lang.NoSuchMethodError: java.lang.String.isEmpty I've just released a new app on
Firstly I am new to android and Java so this is a beginners question.
I am completely new to android, and pretty much a Java newb. I have
I'm new to Java/Eclipse/Android, so this is probably an easy (if not stupid) question:
I have to admit that I'm new to Java and Android. db4o seems to
I know that eclipse can do this, can Intellij via the new Android support
I'm new to Android and I think I'm trying to do something really basic:
I'm new to Android and Java programming and I've manage to create a simple
I am quite new to Android and Java. Before I was working with C++

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.