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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:44:18+00:00 2026-05-27T20:44:18+00:00

I have a issue when I Try to recover information i’ve put into a

  • 0

I have a issue when I Try to recover information i’ve put into a SQLite db. I get a success message that its been put in but when I start my activity that pulls the data it crashes.

LogCat

12-30 22:14:13.005: D/dalvikvm(275): GC_EXTERNAL_ALLOC freed 734 objects / 54696 bytes in 92ms
12-30 22:19:00.275: W/KeyCharacterMap(275): No keyboard for id 0
12-30 22:19:00.275: W/KeyCharacterMap(275): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
12-30 22:19:11.185: D/dalvikvm(275): GC_FOR_MALLOC freed 7425 objects / 301256 bytes in 70ms
12-30 22:19:11.257: E/CursorWindow(275): Bad request for field slot 0,-1. numRows = 8, numColumns = 4
12-30 22:19:11.265: D/AndroidRuntime(275): Shutting down VM
12-30 22:19:11.265: W/dalvikvm(275): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
12-30 22:19:11.285: E/AndroidRuntime(275): FATAL EXCEPTION: main
12-30 22:19:11.285: E/AndroidRuntime(275): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.walkarc.babytracker/com.walkarc.babytracker.BathReport}: java.lang.IllegalStateException: get field slot from row 0 col -1 failed
12-30 22:19:11.285: E/AndroidRuntime(275):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
12-30 22:19:11.285: E/AndroidRuntime(275):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-30 22:19:11.285: E/AndroidRuntime(275):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-30 22:19:11.285: E/AndroidRuntime(275):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-30 22:19:11.285: E/AndroidRuntime(275):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-30 22:19:11.285: E/AndroidRuntime(275):  at android.os.Looper.loop(Looper.java:123)
12-30 22:19:11.285: E/AndroidRuntime(275):  at android.app.ActivityThread.main(ActivityThread.java:4627)
12-30 22:19:11.285: E/AndroidRuntime(275):  at java.lang.reflect.Method.invokeNative(Native Method)
12-30 22:19:11.285: E/AndroidRuntime(275):  at java.lang.reflect.Method.invoke(Method.java:521)
12-30 22:19:11.285: E/AndroidRuntime(275):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-30 22:19:11.285: E/AndroidRuntime(275):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-30 22:19:11.285: E/AndroidRuntime(275):  at dalvik.system.NativeStart.main(Native Method)
12-30 22:19:11.285: E/AndroidRuntime(275): Caused by: java.lang.IllegalStateException: get field slot from row 0 col -1 failed
12-30 22:19:11.285: E/AndroidRuntime(275):  at android.database.CursorWindow.getString_native(Native Method)
12-30 22:19:11.285: E/AndroidRuntime(275):  at android.database.CursorWindow.getString(CursorWindow.java:329)
12-30 22:19:11.285: E/AndroidRuntime(275):  at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:49)
12-30 22:19:11.285: E/AndroidRuntime(275):  at com.walkarc.babytracker.MyDBAdapter.getData(MyDBAdapter.java:91)
12-30 22:19:11.285: E/AndroidRuntime(275):  at com.walkarc.babytracker.BathReport.onCreate(BathReport.java:17)
12-30 22:19:11.285: E/AndroidRuntime(275):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-30 22:19:11.285: E/AndroidRuntime(275):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)

My Entry Code

public long createEntry(String date, String time, String hairWash,
            String comment) {
        // TODO Auto-generated method stub
        ContentValues cv = new ContentValues();
        cv.put(KEY_BATHDATE, date);
        cv.put(KEY_BATHTIME, time);
        cv.put(KEY_HAIRWASH, hairWash);
        cv.put(KEY_COMMENTS, comment);
        return ourDatabase.insert(DATABASE_TABLE, null, cv);
    }

my view xml of the activity of the db retrive

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

    <TableLayout
        android:id="@+id/tableLayout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <TableRow >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:text="Date" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:text="Time" />

            <TextView
                android:id="@+id/textView3"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:text="Hair Wash?" />

            <TextView
                android:id="@+id/textView4"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:text="Comments" />
"

        </TableRow>

        <TextView
            android:id="@+id/textView3"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="get info from db" />
    </TableLayout>

</LinearLayout>

Java for it

    public class BathReport extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.bathreport);
        TextView tv = (TextView) findViewById(R.id.textView3);
        MyDBAdapter info = new MyDBAdapter(this);
        info.open();
        String data = info.getData();
        info.close();
        tv.setText(data);
    }


public String getData() {
        String[] columns = new String[] { KEY_BATHDATE, KEY_BATHTIME,
                KEY_HAIRWASH, KEY_COMMENTS };
        Cursor c = ourDatabase.query(DATABASE_TABLE, columns, null, null, null,
                null, null);
        String result = "";
        int iRow = c.getColumnIndex(KEY_ROWID);
        int iDate = c.getColumnIndex(KEY_BATHDATE);
        int iTime = c.getColumnIndex(KEY_BATHTIME);
        int iHair = c.getColumnIndex(KEY_HAIRWASH);
        int iCom = c.getColumnIndex(KEY_COMMENTS);

        for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
            result = result + c.getString(iRow) + " " + c.getString(iDate)
                    + " " + c.getString(iTime) + " " + c.getString(iHair) + " "
                    + c.getString(iCom) + "\n";
        }

        return result;
    }

Anyone have any idea about why this is erroring out?

  • 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-27T20:44:19+00:00Added an answer on May 27, 2026 at 8:44 pm

    ok, try

    public String getData() {
        String[] columns = new String[] { KEY_BATHDATE, KEY_BATHTIME,
                KEY_HAIRWASH, KEY_COMMENTS };
        Cursor c = ourDatabase.query(DATABASE_TABLE, columns, null, null, null,
                null, null);
        if (c != null && c.moveToFirst()) {
        int iRow = c.getString(0);
        int iDate = c.getString(1);
        int iTime = c.getString(2);
        int iHair = c.getString(3);
        int iCom = c.getString(4);
    
        String[] rData = { iRow, iDate, iTime, iHair, iCom };
    
        return rData;
    
        }
    
        return null;
    }
    

    EDIT

    String[] columns = new String[] { KEY_BATHDATE, KEY_BATHTIME,
                KEY_HAIRWASH, KEY_COMMENTS };
    

    is 4 results, but

        int iRow = c.getColumnIndex(KEY_ROWID);
        int iDate = c.getColumnIndex(KEY_BATHDATE);
        int iTime = c.getColumnIndex(KEY_BATHTIME);
        int iHair = c.getColumnIndex(KEY_HAIRWASH);
        int iCom = c.getColumnIndex(KEY_COMMENTS);
    

    is looking for 5 results. add your _id column

    String[] columns = new String[] { KEY_ROWID, KEY_BATHDATE, KEY_BATHTIME,
                KEY_HAIRWASH, KEY_COMMENTS };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue when I try to rebase an upstream branch into a
I have the following issue using java 1.4 I try to display a very
I have a problem and I will try to explain the issue: I have
I have a fun issue where during application shutdown, try / catch blocks are
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
I have an issue that is driving me a bit nuts: Using a UserProfileManager
I have an issue. When I run: try { $as ->setForename($_POST['fname']) ->setSurname($_POST['sname']) ->setEmail($_POST['email']) ->setUser($_POST['user'])
I have an issue with cakephp's login functionality. When I try to login under
I have an issue where I have two pages that deal with very similar
I have an issue when trying to get Javascript to execute functions in my

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.