public class editprofile extends Activity {
SQLiteDatabase db2;
Button btnSubmit;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pro3);
btnSubmit=(Button)findViewById(R.id.button1);
Button cancel = (Button) findViewById(R.id.buttonc);
Button clear = (Button) findViewById(R.id.buttoncl);
final EditText eid=(EditText) findViewById(R.id.editText1);
final EditText ename=(EditText)findViewById(R.id.editText2);
final EditText epass=(EditText)findViewById(R.id.editText3);
final EditText eyear=(EditText)findViewById(R.id.editText5);
final EditText edept=(EditText)findViewById(R.id.editText6);
final EditText eemail=(EditText)findViewById(R.id.editText7);
cancel.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
Intent inten=new Intent(getApplicationContext(),Elective1Activity.class);
startActivity(inten);
}
});
try{
db2=openOrCreateDatabase("ElectiveDataBase2",SQLiteDatabase.CREATE_IF_NECESSARY,null);
}catch(SQLException e)
{
}
btnSubmit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
ContentValues values=new ContentValues();
values.put("studentid", eid.getText().toString());
values.put("studentname", ename.getText().toString());
values.put("password", epass.getText().toString());
if((db2.update("Studentprofile1",values,"studentid"+"=?" , null))!=-1)
{
Toast.makeText(editprofile.this, "Profile updated Successfully ", 2000).show();
Intent inten=new Intent(getApplicationContext(),Elective1Activity.class);
startActivity(inten);
}
else
{
Toast.makeText(editprofile.this, "profile not updated", 2000).show();
}
}
});
clear.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
eid.setText("");
ename.setText("");
epass.setText("");
edept.setText("");
eyear.setText("");
eemail.setText("");
}
});
}
@Override
protected void onStop() {
db2.close();
super.onStop();
}
}
我想更新表Studentprofile1數據庫ElectiveDataBase2。如果學生輸入他的studentid,名稱,密碼,並單擊提交按鈕,應該在數據庫中更新..請幫助解決這個問題更新SQLite中不工作在Android的
什麼是錯誤您收到?你能告訴我你的logcat嗎? – 2012-03-20 10:35:15