write.insert ("user", null, values); Toast.makeText (SqliteActivity.this, "insert the value of success ______" + values.get ("id"), 1200) show ();.
values.put ("id", 2); values.put ("name", "abc");
write.insert ("user", null, values); Toast.makeText (SqliteActivity.this, "insert the value of success ______" + values.get ("id"), 1200) show ();.
But the error. First run without error, for the first time after being given. Although the error, but the database has data inserted. Here is the error:
Seek expert advice, in the end what's wrong?
<-! Baidu Button BEGIN -> more Share to: <-! Baidu Button END ->
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) -> Reply: ID This field what attributes? Is the primary key right? Should not duplicate values Reply: id int primary key, said id is unique primary key can not have duplicate values are inserted, should start to detect the largest database ID, and then add 1, then insert. Reply: I remember that if you define a primary key, it does not give the assignment id assignment, sqlite will automatically add the value of the primary key column, the default current maximum plus 1 Reply: so? The first use SQLite. I also tried to set the id is not a primary key, but still error Reply: I also tried to set id is not a primary key, but still error. Do not know why? Reply:
I mean, you create a table with a primary key ID after, when data is added, it is not assigned to the id, sqlite will be automatically assigned to the primary key column, I remember this, you can try Reply:
I remember that if you define a primary key, it does not give the assignment id assignment, sqlite will automatically add the value of the primary key column, the default current maximum plus 1
so? The first use SQLite. I also tried to set the id is not a primary key, but still error
I mean, you create a table with a primary key ID after, when data is added, it is not assigned to the id, sqlite will be automatically assigned to the primary key column, I remember this, you can try
Positive solution. The second insert the same data, because id already exists, so an exception is thrown. Reply:
I remember that if you define a primary key, it does not give the assignment id assignment, sqlite will automatically add the value of the primary key column, the default current maximum plus 1
so? The first use SQLite. I also tried to set the id is not a primary key, but still error
I mean, you create a table with a primary key ID after, when data is added, it is not assigned to the id, sqlite will be automatically assigned to the primary key column, I remember this, you can try
Positive solution. The second insert the same data, because id already exists, so an exception is thrown.
but I changed the construction of the table, the primary key or error. So why would an error Reply:
I remember that if you define a primary key, it does not give the assignment id assignment, sqlite will automatically add the value of the primary key column, the default current maximum plus 1
so? The first use SQLite. I also tried to set the id is not a primary key, but still error
I mean, you create a table with a primary key ID after, when data is added, it is not assigned to the id, sqlite will be automatically assigned to the primary key column, I remember this, you can try
But I changed the sentence to build the table, in addition to the primary key, or an error. And ContextValues not write "cv.put (" id ", null);", can not be set to a null value.
Reply:
I remember that if you define a primary key, it does not give the assignment id assignment, sqlite will automatically add the value of the primary key column, the default current maximum plus 1
so? The first use SQLite. I also tried to set the id is not a primary key, but still error
I mean, you create a table with a primary key ID after, when data is added, it is not assigned to the id, sqlite will be automatically assigned to the primary key column, I remember this, you can try
But I changed the sentence to build the table, in addition to the primary key, or an error. And ContextValues not write "cv.put (" id ", null);", can not be set to a null value.
primary key is not removed, you should cv.put ("id", ***); these two removed.
Reply:
I remember that if you define a primary key, it does not give the assignment id assignment, sqlite will automatically add the value of the primary key column, the default current maximum plus 1
so? The first use SQLite. I also tried to set the id is not a primary key, but still error
I mean, you create a table with a primary key ID after, when data is added, it is not assigned to the id, sqlite will be automatically assigned to the primary key column, I remember this, you can try
But I changed the sentence to build the table, in addition to the primary key, or an error. And ContextValues not write "cv.put (" id ", null);", can not be set to a null value.
primary key is not removed, you should cv.put ("id", ***); these two removed.
But I would like to insert a database value, remove the put method, how to insert data into the database?
Reply: Primary key id set to automatically increase. You want to insert the value is the name thing. Each insert a name, id is automatically incremented by 1.
No comments:
Post a Comment