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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:30:36+00:00 2026-06-16T01:30:36+00:00

I have used LogCat to determine the problem line. The SQL String I am

  • 0

I have used LogCat to determine the problem line.

The SQL String I am trying to execute in onCreate is..

CREATE TABLE Routines(_id integer primary key autoincrement, json TEXT);

When it tries to execute this, the problem occurs.

This may well be whats causing the NullPointerException. If you can’t see anything wrong with that, please read on for a bit more background.

This database has not been created yet, I keep getting a NullpointerException, I have compared this to previous SQLite code and the problem is proving evasive.

However, I mention this as it still has to go through the onCreate method. I create a new DatabaseOpenHelper (extending SQliteOpenHelper) in my main code and call the helper’s open() method as seen below.

public void open() throws SQLException
{
    ssDatabase = databaseOpenHelper.getWritableDatabase();
}

If I am not mistaken, as my database has not been created (I made sure of that through uninstalling it prior). The onCreate SQLiteHelper is invoked when that open() method is called.

This is the code where I call that open method.

    try
    {                   
        dbConnector = new DatabaseConnector (this);
        debug = "2 ";

        // This on first start will invoke the database onCreate method - throws SQLException
        dbConnector.open();  /* PROBLEM LINE */
        debug = "3 ";
    }
    catch (Exception e)
    {
        textView1.setText(debug + e.toString());
    }

And this is the code containing my DatabaseOpenHelper and onCreate method

private class DatabaseOpenHelper extends SQLiteOpenHelper
{
    public DatabaseOpenHelper(Context context, String name, CursorFactory factory, int version)
    {
        super(context, name, factory, version); 

        Log.i(TAG, "Constructor");
    }

    // On initial creation of database
    @Override
    public void onCreate(SQLiteDatabase db)
    {
        Log.i(TAG, "Before SQL command");

        String sqlCreateCommand = "CREATE TABLE Routines"
                + "(_id integer primary key autoincrement, "
                + "json TEXT);";

        Log.i(TAG, sqlCreateCommand); 

        // I believe this to be the PROBLEM LINE
        ssDatabase.execSQL(sqlCreateCommand); 

        Log.i(TAG, "Jab done");
    }

    // On upgrade - currently do nothing
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
    {}      
}   

Thanks for the help!

  • 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-16T01:30:37+00:00Added an answer on June 16, 2026 at 1:30 am

    seems like i dont have the prvilege to just post a comment. One question: ssDatabase.execSQL(sqlCreateCommand); –> shouldn’t this be db.execSQL(sqlCreateCommand);
    since the parameter is SQLiteDatabase db. Secondly you use _id. is this index not created by default ? Nevermind if this has nothing to do with it. This were just my thoghts about it. 🙂

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

Sidebar

Related Questions

I have a class called CoverFlowClass. I used to do this to create a
I have used the silverlight control in CRM 2011.It also published on form but
We have used Shibboleth to authenticate users. It works great. The issue is that
I have used some jquery components in my web site, Suddenly i'm getting an
I have used a plugin that uses prototype js, it's working fine but the
I have used NSSets many times in my apps, but I have never created
I have used this website for testing http://www.webpagetest.org and among some suggestions for optimization
I have used auto complete textbox previously. That auto complete works only when i
I have used this code (kind of tutorial) at http://code.google.com/p/gwt-examples/wiki/gwt_hmtl5 ... In this code,
I have used geocoder in my ruby on rails application for a while 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.