package com.example.testdb.dos;
import com.example.testdb.testdatabase;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
public class personDos {
private testdatabase helper;
public personDos(Context context) {
helper = new testdatabase(context);
}
public void add(String name,String number){
SQLiteDatabase db = helper.getWritableDatabase();
db.execSQL("insert into person(name,number) values (?,?)", new Object[](name,number));
db.close();
}
}
以上是全部代碼
Multiple markers at this line
- The constructor Object(String, String) is undefined
- The method execSQL(String, Object[]) in the type SQLiteDatabase is not applicable for the arguments (String,
Object)
- Syntax error on token(s), misplaced construct(s)
這是報的錯誤
db.execSQL("insert into person(name,number) values (?,?)", new Object[](name,number));
改成
db.execSQL("insert into person(name,number) values (?,?)", new Object[]{name,number}); 是大括號