0
private static String[] FROM = { _ID, DESCRIPTION, DATE, TITLE };
    //private static String ORDER_BY = _ID + " DESC" ;
    private Cursor getEvents() {
    // Perform a managed query. The Activity will handle closing
    // and re-querying the cursor when needed.
    SQLiteDatabase db = post.getReadableDatabase();
    Cursor cursor = db.query(TABLE_NAME, FROM, null, null, null,
    null, null);
    startManagingCursor(cursor);
    return cursor;
    }    



private void showEvents(Cursor cursor) {
            TextView tv = new TextView(this);
             // Stuff them all into a big string
             StringBuilder builder = new StringBuilder(
             "Saved events:\n" );
             while (cursor.moveToNext()) {
             // Could use getColumnIndexOrThrow() to get indexes
            long id = cursor.getLong(0);
             String description = cursor.getString(1);
             String date = cursor.getString(2);
             String title = cursor.getString(3);

         builder.append(id).append(": " );
             builder.append(description).append(": " );
             builder.append(date).append(": " );
             builder.append(title).append("\n" );

         }
             // Display on the screen
             tv.setText(builder);
             this.setContentView(tv);

         }

So the showEvents function which is supposed to display the database is displaying a larger database than I created. It is showing 19 rows, yet I only called the insertorthrow function twice so it should have two rows, so I don't know how it can have more than 19 rows. I feel the problem may lie in my getEvents() function or showEvents() function which returns the cursor. Help would be appreciated.

2
  • The database will be persistent so you may be adding rows every time yoou try? Try uninstalling and starting from scratch.
    – Ifor
    Nov 25, 2011 at 21:05
  • derp, yes thats what happened
    – Jake
    Nov 25, 2011 at 21:21

1 Answer 1

0

Using db shell go to the location and delete the database .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.