Click here to Skip to main content
15,890,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am inserting the value using edittext in sqlite and displaying it in listview...after that i clicked on a single row in listview and that single row values are displaying in previous edittext again..now i want to update this edittext value that is coming from listview. Please anyone tell me how to do this?

< Intent intent = getIntent();
name = intent.getStringExtra("Name");
desg = intent.getStringExtra("Designation");

nam= (EditText)findViewById(R.id.NameEditText);
des= (EditText)findViewById(R.id.desgEditText);

nam.setText(name);
des.setText(desg);


insertButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String employeename =nameEditText.getText().toString();
int employeeno =Integer.parseInt(noEditText.getText().toString());
String designation =desgEditText.getText().toString();

dbhelper.insertIntoEmployeeTable(employeename, designation, employeeno);
Log.v("Emp_Name", employeename);
Log.v("Emp_no", String.valueOf(employeeno));
Log.v("Emp_Desg", designation);
Toast.makeText(getBaseContext(), "Your data is inserted",Toast.LENGTH_SHORT).show();
}
});
updateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String employeename =nam.getText().toString();
int employeeno =Integer.parseInt(noEditText.getText().toString());
String designation =des.getText().toString();

dbhelper.updateIntoEmployeeTable(employeename, designation, employeeno);
Log.v("updateEmp_Name", employeename);
Log.v("updateEmp_no", String.valueOf(employeeno));
Log.v("updateEmp_Desg", designation);
Toast.makeText(getBaseContext(), "Your data is updated",Toast.LENGTH_SHORT).show();


}
});
displayButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i=new Intent(MainActivity.this,GridViewActivity.class);
startActivity(i);//start gridview activity to show the records.
}
});
public void updateEmployeeTable(String employeename, String designation, int employeeno){
open();
ContentValues newValues = new ContentValues();
Log.v("UpdateEmployee", employeename + " " + " " + designation);

newValues.put("fld_employeename", employeename);
newValues.put("fld_designation", designation);
newValues.put("fld_employeeno", employeeno);

int update = db.update("tbl_employee", newValues,null, null);
db.close();
Log.v("Update_Query", String.valueOf(update));
}

ArrayList
Posted
Updated 22-Sep-16 0:14am
v2

1 solution

You need to look at startActivityForResults[^]

Here is an example

Intent - Android - Stack Overflow[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900