when i insert the data then insert id always returns -1 this is my data base table.my database is created successfully. So, please tell me what i do to solve this problem.
query3 = "CREATE TABLE IF NOT EXISTS `" + StaticData.SUBJECT_TABLE_NAME + "` ("
+ "`subject_id` int(11) NOT NULL,"
+ "`subject_name` varchar(100) DEFAULT NULL,"
+ " PRIMARY KEY (`subject_id`)"
+ ");";
public long insertSubject(TeacherModel queryValues) {
long insertId = -1;
ContentValues values = new ContentValues();
values.put("id", queryValues.getSubject_id());
values.put("name", queryValues.getSubject());
if(database != null) {
insertId = database.insert(StaticData.SUBJECT_TABLE_NAME, null,
values);
}
Log.w(DataInteract.class.getName(),
"Subject::" + values + "insertID=" + insertId);
return insertId;
}
Aucun commentaire:
Enregistrer un commentaire