如何在sqlite中更新表?

问题描述:

我有两个表首先是TABLE_SUBJECT,第二个是TABLE_CHAPTER。现在我想要
添加一些列并删除之前的。我的问题是如何做到这一点。我尝试更新但是
它显示以前不是新的。我需要用新列删除先前和更新表。

我更改版本号但它不起作用。请给我提示或参考。

I have two table first is "TABLE_SUBJECT" and second is "TABLE_CHAPTER".Now i want to
add some column and delete previous. My question is that how to do that. i try to update but
it display previous not new. I need to delete previous and update table with new column.
I change version number but it not working. Please give me hint or reference.

这是我的一些SQLite代码:

Here is my some code of SQLite:

@Override
public void onCreate(SQLiteDatabase database) {

    database.execSQL(DATABASE_CREATE);
    database.execSQL(DATABASE_CREATE1);

}

 @Override
public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
    // TODO Auto-generated method stub
    Log.w(MySQLiteHelper.class.getName(), "Upgrading database from version "
            + oldVersion + " to " + newVersion
            + ", which will destroy all old data");
    database.execSQL("DROP TABLE IF EXISTS " + TABLE_SUBJECT);
    database.execSQL("DROP TABLE IF EXISTS" + TABLE_CHAPTER);
    onCreate(database);
}


你试试这段代码

public long update_todo_not(String a, String b, String c, String d,
        String e, String f, String g, String id) {
     ContentValues con = new ContentValues();

     con.put("title", a);
     con.put("description", b);
     con.put("due_date", c);
     con.put("alarm_time", d);
     con.put("category", e);
     con.put("alarm_set",f);
     con.put("priority", g);
     Log.v("priority", g+"");
     return mDb.update(DATABASE_TABLE_TODO_LIST, con, "id ='" + id + "'",null);

}