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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:29:29+00:00 2026-05-29T12:29:29+00:00

I am working on an android project that requires a database. The issue that

  • 0

I am working on an android project that requires a database. The issue that I am having is when I go to start it up, i get a nullpointerexception error. Going through the logcat, I have narrowed it down, to when the database updating, and trying to open. Is this normal or am I over looking somthing?
logcat:

02-12 15:41:33.810: ERROR/AndroidRuntime(354): java.lang.RuntimeException: Unable to     start activity ComponentInfo{arch.field/arch.field.ChooseSite}: java.lang.NullPointerException
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at android.os.Looper.loop(Looper.java:123)
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at android.app.ActivityThread.main(ActivityThread.java:3683)
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at java.lang.reflect.Method.invokeNative(Native Method)
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at java.lang.reflect.Method.invoke(Method.java:507)
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at dalvik.system.NativeStart.main(Native Method)
02-12 15:41:33.810: ERROR/AndroidRuntime(354): Caused by: java.lang.NullPointerException
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at arch.field.BmDb$DatabaseHelper.onUpgrade(BmDb.java:96)
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:132)
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at arch.field.BmDb.open(BmDb.java:110)
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at arch.field.ChooseSite.onCreate(ChooseSite.java:30)
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
02-12 15:41:33.810: ERROR/AndroidRuntime(354):     ... 11 more

OnUpgrade code:

public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) 
       {
        Log.d("MonkeyDatabase","DbUpdater");
        db.execSQL("Drop table if exists "+TABLE_SITE_NAME);
        db.execSQL("Drop table if exists "+TABLE_UNIT_NAME);
        db.execSQL("Drop table if exists "+TABLE_BONESHELL_NAME);
        db.execSQL("Drop table if exists "+TABLE_CERAMIC_NAME);
        db.execSQL("Drop table if exists "+TABLE_LITHIC_NAME);
        onCreate(db);
        }

Open code:

public BmDb open() throws SQLException
{
    Log.d("Database","open");
    db= BmDb.getWritableDatabase();
    return this;
}

more code:

public BmDb(Context context)
{
    this.context= context;
    BmDb= new DatabaseHelper(context);
}
public static class DatabaseHelper extends SQLiteOpenHelper
{
    DatabaseHelper(Context context){
        super(context, DATABASE_NAME, null, VERSION);

}

this is the code from the ChooseSite file(with line numbers):

 final BmDb db=new BmDb(this);
    db.open(); **this is the line mentioned in my logcat**
    final Cursor c= db.GetSite();
    if (c.moveToFirst()){
        do{
            sites(c);
        }while (c.moveToNext());
    }

any suggestions on what I am over looking?

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

    from this code

     final BmDb db=new BmDb(this);
    db.open(); **this is the line mentioned in my logcat**
    final Cursor c= db.GetSite();
    if (c.moveToFirst()){
        do{
            sites(c);
        }while (c.moveToNext());
    }
    

    call this mehod twice db.open(); put this in try{}catch{} black.

    as follows try{db.open();db.open();}catch(){}

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

Sidebar

Related Questions

I am currently working on an android project that requires me to invoke a
I'm working on a project that requires developing an android application for a galaxy
I am working on a project that requires me to implement two horizontal scroll
I've got an Android project I'm working on that, ultimately, will require me to
I am working on a android project that can read e-mails from any gmail
I'm working on an Android project that focuses on knowing how close you are
I am working on a android project. I n that I have to deal
I have an Android library project that has been working for me pretty well,
I'm working a personal project that's going to include a home-screen widget updated with
I'm currently working on a project that's based on Android. Without getting into many

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.