android数据库添加超过需要

时间:2011-11-25 20:35:36

标签: android sqlite

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);

         }

因此,应该显示数据库的showEvents函数显示的数据库比我创建的数据库大。它显示了19行,但我只调用了insertorthrow函数两次,因此它应该有两行,所以我不知道它如何能有超过19行。我觉得问题可能在于我的getEvents()函数或showEvents()函数返回游标。帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

使用db shell转到该位置并删除数据库。