android SQLite table book有4列,但提供了5个值

android SQLite table book有4列,但提供了5个值,android,sqlite,Android,Sqlite,是,我插入了4个值,但错误消息显示提供了5个值 这是我的DB类 title = intent.getStringExtra("TITLE"); author = intent.getStringExtra("AUTHOR"); rating = intent.getFloatExtra("RATING", (float) 0.0); quotes = intent.getStringExtra("QUOTES"); myDBHelper = new MyDBHe

是,我插入了4个值,但错误消息显示提供了5个值

这是我的DB类

title = intent.getStringExtra("TITLE");
    author = intent.getStringExtra("AUTHOR");
    rating = intent.getFloatExtra("RATING", (float) 0.0);
    quotes = intent.getStringExtra("QUOTES");

    myDBHelper = new MyDBHelper(getApplicationContext());

    SQLiteDatabase db = myDBHelper.getWritableDatabase();

    String sql = String.format("INSERT INTO book VALUES(null,'%s','%s',%f,'%s')",title,author,rating,quotes);
我在logcat上看到了这个消息

    @Override
    public void onCreate(SQLiteDatabase db) {

        String sql = "CREATE TABLE book ( _id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT , author TEXT , rating REAL , quotes TEXT);";
        db.execSQL(sql);


    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

        String sql = "DROP TABLE book IF EXISTS book;";
        db.execSQL(sql);

        onCreate(db);

    }

为什么???

我看到有5个数据值。你可以这样插入

12-12 22:22:57.740 9757-9757/? E/AndroidRuntime: ... table book has 4 columns but 5 values were supplied: , while compiling: INSERT INTO book VALUES(null,'null','null',0.000000,'null')

它应该可以工作。

看起来像5个数据值:null、%s、%s、%f、%s
    ContentValues values = new ContentValues();
    values.put("title", intent.getStringExtra("TITLE"));
    values.put("author", intent.getStringExtra("AUTHOR"));
    values.put("rating", intent.getFloatExtra("RATING", (float) 0.0));
    values.put("quotes", intent.getStringExtra("QUOTES"));
    // Inserting Row
    db.insert("book", null, values);