1. In your create table String,
String newTableQueryString =
"create table " +
TABLE_NAME +
" (" +
TABLE_ROW_ID + " integer primary key autoincrement not null, " +
TABLE_ROW_ONE + " text, " +
TABLE_ROW_TWO + " text, " +
TABLE_ROW_THREE + " text, " +
TABLE_ROW_FOUR + " text" +
");";
The ROW_ID is an integer, so in your function updateRow()
, the data type for parameter of rowID
should be integer, which is passed in the “where” clause. So should change
-> public void updateRow(long rowID, String rowStringOne,...
2. To identify the row you have added, you need to have a primary key which you will be able to identify on the basis of the entry.
Auto increment integer is good for ensuring that the database will have a new row each time,
but the primary key you need should be something you will know to differentiate entries.
Can try a derived key which would be another column in your db, to insert the same with adding rows would be like:
String customPrimaryKey="UserName.getText().toString()+FirstName.getText().toString()+txtPassword.getText().toString()";
db.updateRow
(
UserName.getText().toString(),
FirstName.getText().toString(),
LastName.getText().toString(),
txtPassword.getText().toString(),
// add one more value for a particular entry-a primary key for You to identify that row
customPrimaryKey
);
So you have a way to identify which row to update then, and pass the same in the updateRow()
parameters for the where clause
3
solved Unable to update a record in sqlite database