这是我在该应用程序的数据库中插入行的方法。但是它只插入一行。 所以我要做的就是在数据库中添加多行。这个代码我用于我的应用程序中的新用户注册。如何在数据库中插入多行?
在此先感谢.....
public void addProductToCart(String username, String password,
String email, String contact, String bloodgroup, String city, String state) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(colUsername, username);
contentValues.put(colPassword, password);
contentValues.put(colEmail, email);
contentValues.put(colContact, contact);
contentValues.put(colBloodgroup, bloodgroup);
contentValues.put(colCity, city);
contentValues.put(colState, state);
db.insert(USERTABLE, colUsername, contentValues);
db.close();
context.runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(context, "You have registered successfully.",
Toast.LENGTH_LONG).show();
context.finish();
}
});
}
为什么你需要一次插入多行? – wolverine 2012-04-05 13:29:51
我希望它在应用程序中注册。由于使用此代码,我只能注册一次。它的完全多用户应用程序。通过此注册成功完成,但数据不会进入数据库。 – 2012-04-05 14:14:45