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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:15:04+00:00 2026-06-18T17:15:04+00:00

Every time i run my app the Null Pointer casts at logcat how can

  • 0

Every time i run my app the Null Pointer casts at logcat how can i know where the error is ive tried the debugging in eclipse but i still can`t figure it out ,

here is the logcat error at first the error i found was no such column exists i have fixed it now this is the error:

02-12 00:16:40.837: D/AndroidRuntime(360): Shutting down VM
02-12 00:16:40.837: W/dalvikvm(360): threadid=1: thread exiting with uncaught exception                (group=0x40015560)
02-12 00:16:40.868: E/AndroidRuntime(360): FATAL EXCEPTION: main
02-12 00:16:40.868: E/AndroidRuntime(360): java.lang.RuntimeException: Unable to start     activity ComponentInfo{com.example.database/com.example.database.AndroidSQLite}:     java.lang.NullPointerException
02-12 00:16:40.868: E/AndroidRuntime(360):  at   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
02-12 00:16:40.868: E/AndroidRuntime(360):  at     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-12 00:16:40.868: E/AndroidRuntime(360):  at     android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-12 00:16:40.868: E/AndroidRuntime(360):  at     android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-12 00:16:40.868: E/AndroidRuntime(360):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-12 00:16:40.868: E/AndroidRuntime(360):  at android.os.Looper.loop(Looper.java:123)
02-12 00:16:40.868: E/AndroidRuntime(360):  at android.app.ActivityThread.main(ActivityThread.java:3683)
02-12 00:16:40.868: E/AndroidRuntime(360):  at     java.lang.reflect.Method.invokeNative(Native Method)
02-12 00:16:40.868: E/AndroidRuntime(360):  at     java.lang.reflect.Method.invoke(Method.java:507)
02-12 00:16:40.868: E/AndroidRuntime(360):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-12 00:16:40.868: E/AndroidRuntime(360):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-12 00:16:40.868: E/AndroidRuntime(360):  at dalvik.system.NativeStart.main(Native     Method)
02-12 00:16:40.868: E/AndroidRuntime(360): Caused by: java.lang.NullPointerException
02-12 00:16:40.868: E/AndroidRuntime(360):  at     com.example.database.AndroidSQLite.onCreate(AndroidSQLite.java:58)
02-12 00:16:40.868: E/AndroidRuntime(360):  at     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-12 00:16:40.868: E/AndroidRuntime(360):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
02-12 00:16:40.868: E/AndroidRuntime(360):  ... 11 more
02-12 00:16:42.977: I/Process(360): Sending signal. PID: 360 SIG: 9

here is my code:

     package com.example.database;

     import android.content.ContentValues;
     import android.content.Context;
     import android.database.Cursor;
     import android.database.sqlite.SQLiteDatabase;
     import android.database.sqlite.SQLiteOpenHelper;
     import android.database.sqlite.SQLiteDatabase.CursorFactory;

     public class SQLiteAdapter {

      public static final String MYDATABASE_NAME = "SCORING";
      public static final String MYDATABASE_TABLE = "SCORING_TABLE";
      public static final int MYDATABASE_VERSION = 3;
      public static final String KEY_ID = "_id";
      public static final String KEY_CONTENT1 = "Content1";
      public static final String KEY_CONTENT2 = "Content2";
      public static final String KEY_CONTENT3 = "Content3";

      //create table SCORING (ID integer primary key, Content text not null);
      private static final String SCRIPT_CREATE_DATABASE =
       "create table " + MYDATABASE_TABLE + " ("
       + KEY_ID + " integer primary key autoincrement, "
       + KEY_CONTENT1 + " text not null, "
       + KEY_CONTENT2 + " text not null, "
       + KEY_CONTENT3 + "text not null);";

      private SQLiteHelper sqLiteHelper;
      private SQLiteDatabase sqLiteDatabase;

      private Context context;

      public SQLiteAdapter(Context c){
       context = c;
      }

      public SQLiteAdapter openToRead() throws android.database.SQLException {
       sqLiteHelper = new SQLiteHelper(context, MYDATABASE_NAME, null,                                  MYDATABASE_VERSION);
          sqLiteDatabase = sqLiteHelper.getReadableDatabase();
        return this; 
            }

       public SQLiteAdapter openToWrite() throws android.database.SQLException {
        sqLiteHelper = new SQLiteHelper(context, MYDATABASE_NAME, null,             MYDATABASE_VERSION);
        sqLiteDatabase = sqLiteHelper.getWritableDatabase();
        return this; 
       }

       public void close(){
        sqLiteHelper.close();
       }

       public long insert(String content1, String content2, String content3){          

        ContentValues contentValues = new ContentValues();
        contentValues.put(KEY_CONTENT1, content1);
        contentValues.put(KEY_CONTENT2, content2);
        contentValues.put(KEY_CONTENT3, content3);
        return sqLiteDatabase.insert(MYDATABASE_TABLE, null, contentValues);
       }

       public int deleteAll(){
        return sqLiteDatabase.delete(MYDATABASE_TABLE, null, null);
       }

       public Cursor queueAll(){
        String[] columns = new String[]{KEY_ID, KEY_CONTENT1, KEY_CONTENT2,    KEY_CONTENT3};
        Cursor cursor = sqLiteDatabase.query(MYDATABASE_TABLE, columns,
          null, null, null, null, null);

        return cursor;
       }

       public class SQLiteHelper extends SQLiteOpenHelper {

        public SQLiteHelper(Context context, String name,
          CursorFactory factory, int version) {
         super(context, name, factory, version);
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
         // TODO Auto-generated method stub
         db.execSQL(SCRIPT_CREATE_DATABASE);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
         // TODO Auto-generated method stub
        // If you need to add a column
    if (newVersion > oldVersion) {
        db.execSQL("ALTER TABLE SCORING_TABLE ADD COLUMN Content4 TEXT");
    }
        }
       } 
      }

now i got the second error in this part

02-12 00:54:03.516: D/AndroidRuntime(359): Shutting down VM
02-12 00:54:03.516: W/dalvikvm(359): threadid=1: thread exiting with uncaught exception     (group=0x40015560)
02-12 00:54:03.546: E/AndroidRuntime(359): FATAL EXCEPTION: main
02-12 00:54:03.546: E/AndroidRuntime(359): java.lang.ArrayIndexOutOfBoundsException
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.widget.SimpleCursorAdapter.bindView(SimpleCursorAdapter.java:130)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.widget.CursorAdapter.getView(CursorAdapter.java:186)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.widget.AbsListView.obtainView(AbsListView.java:1430)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.widget.ListView.makeAndAddView(ListView.java:1745)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.widget.ListView.fillDown(ListView.java:670)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.widget.ListView.fillFromTop(ListView.java:727)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.widget.ListView.layoutChildren(ListView.java:1584)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.widget.AbsListView.onLayout(AbsListView.java:1260)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.view.View.layout(View.java:7175)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.view.View.layout(View.java:7175)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.view.View.layout(View.java:7175)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.view.View.layout(View.java:7175)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.view.View.layout(View.java:7175)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.view.ViewRoot.performTraversals(ViewRoot.java:1140)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.os.Looper.loop(Looper.java:123)
02-12 00:54:03.546: E/AndroidRuntime(359):  at android.app.ActivityThread.main(ActivityThread.java:3683)
02-12 00:54:03.546: E/AndroidRuntime(359):  at java.lang.reflect.Method.invokeNative(Native Method)
02-12 00:54:03.546: E/AndroidRuntime(359):  at     java.lang.reflect.Method.invoke(Method.java:507)
02-12 00:54:03.546: E/AndroidRuntime(359):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-12 00:54:03.546: E/AndroidRuntime(359):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-12 00:54:03.546: E/AndroidRuntime(359):  at dalvik.system.NativeStart.main(Native Method)
02-12 00:54:05.646: I/Process(359): Sending signal. PID: 359 SIG: 9

and its class:

        package com.example.database;



    import com.example.database.R;
    import android.app.Activity;
    import android.content.Intent;
    import android.database.Cursor;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.ListView;
    import android.widget.SimpleCursorAdapter;
    import android.widget.TextView;
    import android.widget.Toast;

    public class AndroidSQLite extends Activity {

     EditText  inputContent2;
     TextView textView1, textView2;
     Button buttonAdd, buttonDeleteAll;

     private SQLiteAdapter mySQLiteAdapter;
     ListView listContent;

     SimpleCursorAdapter cursorAdapter;
     Cursor cursor;

       /** Called when the activity is first created. */
       @Override
       public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.main);


           textView1 = (TextView)findViewById(R.id.textView1);
           textView2 = (TextView)findViewById(R.id.textView2);
           inputContent2 = (EditText)findViewById(R.id.content2);
           buttonAdd = (Button)findViewById(R.id.add);
           buttonDeleteAll = (Button)findViewById(R.id.deleteall);
          listContent = (ListView)findViewById(R.id.contentlist);

           mySQLiteAdapter = new SQLiteAdapter(this);
           mySQLiteAdapter.openToWrite();

           cursor = mySQLiteAdapter.queueAll();
           String[] from = new String[]{SQLiteAdapter.KEY_ID, SQLiteAdapter.KEY_CONTENT1,         SQLiteAdapter.KEY_CONTENT2};
           int[] to = new int[]{R.id.id, R.id.text1, R.id.text2, R.id.text3};
           cursorAdapter =
            new SimpleCursorAdapter(this, R.layout.row, cursor, from, to);
           listContent.setAdapter(cursorAdapter);

           buttonAdd.setOnClickListener(buttonAddOnClickListener);
           buttonDeleteAll.setOnClickListener(buttonDeleteAllOnClickListener);



       }

       Button.OnClickListener buttonAddOnClickListener
       = new Button.OnClickListener(){

      @Override
      public void onClick(View arg0) {
       // TODO Auto-generated method stub 
             int a=Integer.parseInt(textView1.getText().toString());
             int  b=a+2;
          String s1 = String.valueOf(b);
          textView1.setText(s1);
         Toast.makeText(getApplicationContext(), "Wrong",
                    Toast.LENGTH_SHORT).show();

       String data1 = textView1.getText().toString();
       String data2 = inputContent2.getText().toString();
       String data3 = textView2.getText().toString();
       mySQLiteAdapter.insert(data1, data2, data3);
       updateList();



      }

       };


       Button.OnClickListener buttonDeleteAllOnClickListener
       = new Button.OnClickListener(){

      @Override
      public void onClick(View arg0) {
       // TODO Auto-generated method stub
       mySQLiteAdapter.deleteAll();
       updateList();
      }

       };

     @Override
     protected void onDestroy() {
      // TODO Auto-generated method stub
      super.onDestroy();
      mySQLiteAdapter.close();
     }        



     private void updateList(){
      cursor.requery();
       }

    }

as for the xml layout here it is:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   >


<TextView 
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="hello"
   />
<TextView 
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="Enter content of column 1"
   />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="0"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView 
       android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="Enter content of column 2"
   />
<EditText
   android:id="@+id/content2"
   android:layout_width="fill_parent"
       android:layout_height="wrap_content"
   />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<Button
   android:id="@+id/add"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="Add"
   />

<Button
   android:id="@+id/deleteall"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="Delete All"
   />
<ListView
 android:id="@+id/contentlist"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"/>
</LinearLayout>
  • 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-18T17:15:06+00:00Added an answer on June 18, 2026 at 5:15 pm

    Quite simply, you have three values in your from array, but four in to. These two arrays must match (with a one-to-one relationship):

    String[] from = new String[]{SQLiteAdapter.KEY_ID, SQLiteAdapter.KEY_CONTENT1, SQLiteAdapter.KEY_CONTENT2};
    int[] to = new int[]{R.id.id, R.id.text1, R.id.text2, R.id.text3};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The app will run fine, then crash - literally every other time. It seems
im really desperate right now, ive tried everything. Everytime i run my app this
Every time I run my app and it tries to connect to facebook it
Almost every time I run my MVC app, it stops with errors before getting
Every single time I run my app, I want a new log file to
Every time I run the code below it is supposed to come up with
I have this warning every time I run my CGI-script (output is rendered by
I'm running through the gitimmersion.com labs and every time I run a: git hist
I am getting a warning I do not fully understand every time I run
I have a spork gem issue. Every time I run the spork command I

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.