Code example for ContentValues

Methods: putputNull

0
            StringBuilder sb = new StringBuilder();
            sb.append("CREATE TABLE answers( _id integer primary key autoincrement, name TEXT NOT NULL, quest TEXT NOT NULL, favoritecolor INTEGER DEFAULT -1, otheranswer TEXT DEFAULT NULL);");
 
            sqLiteDatabase.execSQL(sb.toString());
 
            ContentValues cv = new ContentValues();
            cv.put(Columns.Name, "Sir Lancelot of Camelot");
            cv.put(Columns.Quest, "To seek the Holy Grail");
            cv.put(Columns.FavoriteColor, 0xFF0000FF);
            cv.putNull(Columns.OtherAnswer);
            sqLiteDatabase.insert("answers", null, cv);
 
            cv = new ContentValues();
            cv.put(Columns.Name, "Sir Robin of Camelot");
            cv.put(Columns.Quest, "To seek the Holy Grail");
            cv.put(Columns.OtherAnswer, "I don't know that!! AAAAAAHHH!!!!");
            sqLiteDatabase.insert("answers", null, cv);
 
            cv = new ContentValues();
            cv.put(Columns.Name, "Sir Galahad of Camelot");
            cv.put(Columns.Quest, "I seek the Grail");