What is the correct way to do inserts/updates/deletes in Android SQLiteDatabase using a query string?

前端 未结 2 617
一整个雨季
一整个雨季 2020-11-30 12:56

I\'ve been looking at the official documentation (http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html) and cross-referencing with StackOverflo

2条回答
  •  臣服心动
    2020-11-30 13:49

    What you want is execSQL() for inserts. Or you can do it this way:

    ContentValues values = new ContentValues();
    values.put ("col1", "foo");
    values.put ("cols2", "bar");
    getDb().insertOrThrow ("MyTable", null, values);
    

    For queries, you can use rawQuery.

提交回复
热议问题