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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:09:26+00:00 2026-05-16T00:09:26+00:00

the error in my logcat is such Logcat 08-29 08:20:57.961: ERROR/AndroidRuntime(1766): java.lang.RuntimeException: Unable to

  • 0

the error in my logcat is such

Logcat

08-29 08:20:57.961: ERROR/AndroidRuntime(1766): java.lang.RuntimeException: Unable to start activity ComponentInfo{one.two/one.two.Booking}: java.lang.IllegalArgumentException: column '_id' does not exist
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at android.app.ActivityThread.access$1800(ActivityThread.java:112)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at android.os.Looper.loop(Looper.java:123)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at android.app.ActivityThread.main(ActivityThread.java:3948)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at java.lang.reflect.Method.invokeNative(Native Method)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at java.lang.reflect.Method.invoke(Method.java:521)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at dalvik.system.NativeStart.main(Native Method)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766): Caused by: java.lang.IllegalArgumentException: column '_id' does not exist
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:314)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at android.widget.CursorAdapter.init(CursorAdapter.java:111)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at android.widget.CursorAdapter.<init>(CursorAdapter.java:90)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at android.widget.ResourceCursorAdapter.<init>(ResourceCursorAdapter.java:47)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at android.widget.SimpleCursorAdapter.<init>(SimpleCursorAdapter.java:85)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at one.two.Booking.onCreate(Booking.java:34)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
08-29 08:20:57.961: ERROR/AndroidRuntime(1766):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)

Part of my DBAdapter.java

public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        db = new DBAdapter(this);
        db.open();
        setContentView(R.layout.booking);
        /*long id; 
        id = db.insertTime(
        new String("08:00")); */
        Cursor spinnerCursor = db.getSpinnerData(); 
        startManagingCursor(spinnerCursor);
        Spinner colourSpinner = (Spinner) findViewById(R.id.spinner);

Creation of DB

package one.two;


import java.io.IOException;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DBAdapter 
{   
    private static String DB_PATH = "/data/data/one.two/databases/"; 
    private static String DB_NAME = "irsyad";

    //values for the login table
    public static final String KEY_ROWID = "_id";
    public static final String KEY_USERNAME = "Username";
    public static final String KEY_PASSWORD = "Password";
    public static final String KEY_LNAME = "LastName";
    public static final String KEY_FNAME ="FirstName";

    public static final String KEY_ROWID2 = "_id";
    public static final String KEY_STATUS = "status";
    public static final String KEY_DESTINATION = "destination";
    public static final String KEY_ARRIVAL = "arrival";
    public static final String KEY_FERRY ="ferry";

    private static final String TAG = "DBAdapter";

    //declare Database name, tables names
    private static final String DATABASE_NAME = "irsyad";
    private static final String DATABASE_TABLE = "User";
    private static final String DATABASE_TABLE_2 = "port";
    private static final int DATABASE_VERSION = 1;

    //declares the rules for the database tables
    private static final String DATABASE_CREATE =
        "create table user (_id integer primary key autoincrement, "
        + "Username text not null, Password text not null,"
        + "LastName text not null, FirstName text not null);";

    private static final String DATABASE_CREATE_2 =
        "create table port (_id integer primary key autoincrement, "
        + "status text null, destination text null,"
        + "arrival text null, ferry text null);";

    private final Context context; 

    private DatabaseHelper DBHelper;
    private SQLiteDatabase db;

    public DBAdapter(Context ctx) 
    {
        this.context = ctx;
        DBHelper = new DatabaseHelper(context);
    }

    private static class DatabaseHelper extends SQLiteOpenHelper 
    {
        DatabaseHelper(Context context) 
        {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }

        //Create the tables with the rules we set.
        @Override
        public void onCreate(SQLiteDatabase db) 
        {
            db.execSQL(DATABASE_CREATE);
            db.execSQL(DATABASE_CREATE_2);
        }

        //OnUpgrade is only for use when u changed the database's version to 2 etc.
        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, 
        int newVersion) 
        {
            Log.w(TAG, "Upgrading database from version " + oldVersion 
                    + " to "
                    + newVersion + ", which will destroy all old data");
            db.execSQL("DROP TABLE IF EXISTS port");
            onCreate(db);
        }
    }    

    //---opens the database---
    public DBAdapter open() throws SQLException 
    {
        db = DBHelper.getWritableDatabase();
        return this;
    }

    //---closes the database---    
    public void close() 
    {
        DBHelper.close();
    }

    //Method for inserting login details, can be used in other java files when DBAdapter is
    //declared in the java file. e.g. DBAdapter db = new DBAdapter(this);
    public long insertUser(String Username, String Password, String LastName, String FirstName) 
    {
        ContentValues initialValues = new ContentValues();
        initialValues.put(KEY_USERNAME, Username);
        initialValues.put(KEY_PASSWORD, Password);
        initialValues.put(KEY_LNAME, LastName);
        initialValues.put(KEY_FNAME, FirstName);
        return db.insert(DATABASE_TABLE, null, initialValues);
    }
   /* public long insertTime(String arrival) 
    { 
    ContentValues initialValue = new ContentValues(); 
    initialValue.put(KEY_ARRIVAL, arrival); 
    return db.insert(DATABASE_TABLE_2, KEY_ARRIVAL, initialValue); 
    }*/

    //---deletes a particular title---
    public boolean deleteUser(long rowId) 
    {
        return db.delete(DATABASE_TABLE, KEY_ROWID + 
                "=" + rowId, null) > 0;
    }

    //method for retrieving all the inputs from database
    public Cursor getAllUser() 
    {
        return db.query(DATABASE_TABLE, new String[] {
                KEY_ROWID, 
                KEY_USERNAME,
                KEY_PASSWORD,
                KEY_LNAME,
                KEY_FNAME,},
                null, 
                null, 
                null, 
                null, 
                null);
    }   

    public Cursor getAllData() 
    {
        return db.query(DATABASE_TABLE_2, new String[] {
                KEY_ROWID2, 
                KEY_STATUS,
                KEY_DESTINATION,
                KEY_ARRIVAL,
                KEY_FERRY,},
                null, 
                null, 
                null, 
                null, 
                null);
    }   

    //---retrieves a particular title---
    public Cursor getUser(long rowId) throws SQLException 
    {
        Cursor mCursor =
                db.query(true, DATABASE_TABLE, new String[] {
                        KEY_ROWID,
                        KEY_USERNAME, 
                        KEY_PASSWORD,
                        KEY_LNAME,
                        KEY_FNAME,}, 
                        KEY_ROWID + "=" + rowId, 
                        null,
                        null, 
                        null, 
                        null, 
                        null);
        if (mCursor != null) {
            mCursor.moveToFirst();
        }
        return mCursor;
    }

    public Cursor getSpinnerData() throws SQLException 
    {
        Cursor mCursor =
                db.query(DATABASE_TABLE_2, new String[] {               
                        KEY_ARRIVAL,}, 
                        null,
                        null, 
                        null, 
                        null, 
                        null);
        if (mCursor != null) {
            mCursor.moveToFirst();
        }
        return mCursor;
    }

    //---updates a title---
    public boolean updateUser(long rowId, String Username, String Password, String LastName, String FirstName)
    {
        ContentValues args = new ContentValues();
        args.put(KEY_USERNAME, Username);
        args.put(KEY_PASSWORD, Password);
        args.put(KEY_LNAME, LastName);
        args.put(KEY_FNAME, FirstName);
        return db.update(DATABASE_TABLE, args, 
                         KEY_ROWID + "=" + rowId, null) > 0;
    }

    private boolean checkDataBase()
    {

        SQLiteDatabase checkDB = null;

        try
        {
            String myPath = DB_PATH + DB_NAME;
            checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READWRITE);

        }
        catch(SQLiteException e)
        {
            //database does't exist yet.
        }

        if(checkDB != null)
        {
            checkDB.close();
        }

        return checkDB != null ? true : false;
    }

    public void createDataBase() throws IOException
    {

        boolean dbExist = checkDataBase();

        if(dbExist)
        {
            //do nothing - database already exist
        }
        else
        {
             db.execSQL(DATABASE_CREATE);
             db.execSQL(DATABASE_CREATE_2);

        }
    }
}
  • 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-16T00:09:27+00:00Added an answer on May 16, 2026 at 12:09 am

    You are not including _id in your column list for the query you do in getSpinnerData().

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

Sidebar

Ask A Question

Stats

  • Questions 466k
  • Answers 466k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can do this in pure CSS: /* set rule:… May 16, 2026 at 1:52 am
  • Editorial Team
    Editorial Team added an answer As you have invited I am going to recommend HashMap… May 16, 2026 at 1:52 am
  • Editorial Team
    Editorial Team added an answer The exp function doesn't do exponents really, it does something… May 16, 2026 at 1:52 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.