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

The Archive Base Latest Questions

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

My app always crash at the beginning the error is in the log My

  • 0

My app always crash at the beginning the error is in the log

My Code:

    private void onCreateDBAndDBTabled() {
        myDB = this.openOrCreateDatabase(MY_DB_NAME, MODE_PRIVATE, null);
        //myDB.execSQL("DROP TABLE " + MY_DB_TABLE);
        myDB.execSQL("CREATE TABLE IF NOT EXISTS " + MY_DB_TABLE
                + " (_id integer primary key autoincrement, name varchar(100), rate integer(1), eattime varchar(100),image BLOB)"
                +";");
    ArrayList<Pizza> list = new ArrayList<Pizza>();
Cursor cursor = this.myDB.query(MY_DB_TABLE, new String[] { "name", "rate","eattime" },null,null,null,null,null,null);
      if (cursor.moveToFirst()) {
         do {
             Log.e("XXX", "Courser Enter: " + cursor.getString(0));
             Pizza pizza = new Pizza();
             pizza.title= cursor.getString(0);
             pizza.rate = cursor.getInt(1);
             pizza.date = cursor.getString(2);

             ByteArrayInputStream inputStream = new ByteArrayInputStream(cursor.getBlob(3));
             pizza.picture = BitmapFactory.decodeStream(inputStream);
            list.add(pizza); 
            } 
         while (cursor.moveToNext());
      }
      if (cursor != null && !cursor.isClosed()) {
         cursor.close();
      }
      Log.e("XXX", "Count:" + list.size());
      //Log.e("XXX", "Item[0] -->" +  list.toArray()[0].toString());
      CustomAdapter aa = new CustomAdapter(this, R.layout.customlistitem,list);
     Log.e("XXX", String.valueOf(aa.getCount()));
      lv.setAdapter(aa);
      aa.notifyDataSetChanged();
    }

AddPizza:

private void addData() {
        myDB = this.openOrCreateDatabase(MY_DB_NAME, MODE_PRIVATE, null);
        //myDB.execSQL("DROP TABLE " + MY_DB_TABLE);
        myDB.execSQL("CREATE TABLE IF NOT EXISTS " + MY_DB_TABLE
                    + " (_id integer primary key autoincrement, name varchar(100), rate integer(1), eattime varchar(100),image BLOB)"
                    +";");
        if(!name.getText().equals("") && rating.getRating()!=0.0)
        {
            Log.e("XXX", "Enter_Insert");
            Calendar cal = Calendar.getInstance(); 
            DateFormat formatter = new SimpleDateFormat(); 
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            Bitmap bt = ((BitmapDrawable)iv.getDrawable()).getBitmap();
            bt.compress(Bitmap.CompressFormat.PNG, 100, out);
            ContentValues cv = new ContentValues();
            cv.put("image", out.toByteArray());            
            cv.put("name", name.getText().toString());
            cv.put("eattime", formatter.format(cal.getTime()));
            cv.put("rate", rating.getRating());
            myDB.insert(MY_DB_TABLE, null, cv);

            //myDB.execSQL("INSERT INTO "+ MY_DB_TABLE + "(name,rate,eattime,image) VALUES +" +  + ", " ++ " , datetime('now', 'localtime'), " );
        }

    }

LOG:

09-30 12:16:26.755: ERROR/AndroidRuntime(1149): Caused by: java.lang.IllegalStateException: get field slot from row 0 col 3 failed
09-30 12:16:26.755: ERROR/AndroidRuntime(1149):     at android.database.CursorWindow.getBlob_native(Native Method)
09-30 12:16:26.755: ERROR/AndroidRuntime(1149):     at android.database.CursorWindow.getBlob(CursorWindow.java:242)
09-30 12:16:26.755: ERROR/AndroidRuntime(1149):     at android.database.AbstractWindowedCursor.getBlob(AbstractWindowedCursor.java:35)
09-30 12:16:26.755: ERROR/AndroidRuntime(1149):     at com.korn.pizzacounter.Main.onCreateDBAndDBTabled(Main.java:70)
09-30 12:16:26.755: ERROR/AndroidRuntime(1149):     at com.korn.pizzacounter.Main.onCreate(Main.java:40)
09-30 12:16:26.755: ERROR/AndroidRuntime(1149):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-30 12:16:26.755: ERROR/AndroidRuntime(1149):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
  • 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-26T00:04:31+00:00Added an answer on May 26, 2026 at 12:04 am

    The fourth column is missing in the DB query statement. You only declare “name”, “rate”, “eattime”, but not “image”.

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

Sidebar

Related Questions

Maybe it's wrong but I always use this query for my app: cme_only =
I have this weird crash that only happens when running the app on the
I am facing crash issue in native of my android code. My app is
My client wants their app to always show a WARNING screen when the application
Guys, I have a basic WPF application. Contains App.xaml as always and a Mainwindow.xaml.
I have an app where there is always a current contest (defined by start_date
I want the window to be always in front of all of the app
The Salesforce.com API seems to assume that you will always use the app as
I am currently developing an android app, there is always unexpected exception popup when
GNU libc's backtrace and In-circuit emulators/debuggers are not always available when porting code to

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.