at first…I don’t want it change my PRIMARY KEY….
and here’s the create method of my DB….
public void onCreate(SQLiteDatabase db) {
String DATABASE_CREATE_TABLE =
"create table userData ("
+ "_id INTEGER PRIMARY KEY AUTOINCREMENT,"
+ "HTTPorS TEXT,"
+ "IPHostName TEXT,"
+ "port TEXT,"
+ "userName TEXT,"
+ "password TEXT,"
+ "saveOption TEXT"
+ ");";
db.execSQL(DATABASE_CREATE_TABLE);
}
and this is how I add row in it
public long create(String HTTPorS, String IPHostName, String port, String userName, String password, String saveOption) {
ContentValues args = new ContentValues();
args.put("HTTPorS", HTTPorS);
args.put("IPHostName", IPHostName);
args.put("port", port);
args.put("userName", userName);
args.put("password", password);
args.put("saveOption", saveOption);
return db.insert("userData", null, args);
}
Both 2 methods up before work fine…But when I want to change Value of rows…
I use this Method
public void update(long rowId,String httporS, String IP,String Port,String userName,String password) {
ContentValues args = new ContentValues();
args.put("HTTPorS", httporS);
args.put("IPHostName", IP);
args.put("port", Port);
args.put("userName", userName);
args.put("password", password);
args.put("saveOption", "no use");
db.update("userData",
args,
"_id=" + rowId,
null
);
}
It runs normal,and the correct values 「do」 get in this Method…
but the db’s data didn’t replace
why is that?
thanks for your help!
_id is an INTEGER
Your rowId should be modified to an integer to update the db.
long -> int