mercredi 24 juin 2015

how to set the data returned by database to edittext

I am trying view data view by unique id, I want use phone as unique id I created following database code

public String getEmpName(String empphone) throws SQLException {
    String[] columns = new String[] { EMP_ID, EMP_NAME, EMP_DOB, EMP_ADDR, EMP_PHONE };
    Cursor c = ourDatabase.query(EMPINFO_TABLE_NAME, columns, KEY_ROWID + "="
            + empphone, null, null, null, null, null);

    String result = "";

    int iRow = c.getColumnIndex(EMP_ID);
    int iName = c.getColumnIndex(EMP_NAME);
    int iADDR = c.getColumnIndex(EMP_ADDR);
    int iPHONE = c.getColumnIndex(EMP_PHONE);
    int iDOB = c.getColumnIndex(EMP_DOB);

    for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
        result = result + c.getString(iRow) + " " + c.getString(iName)
                + " " + c.getString(iADDR)+ " " + c.getString(iPHONE)+ " " + c.getString(iDOB)
                + "\n";

    }
    return result;
}

employee class

here i want to set the data returned to given edit texts, i.e. phone number should be seen in phoneedittext, name should be seen on nameedittext and so on

public void onClick(View view){

    String empname=nameedittext.getText().toString();
    String empdateofbirth=dateedittext.getText().toString();
    String empaddress=addressedittext.getText().toString();
    String empphone=phoneedittext.getText().toString();

    dbhandle.getEmpName(empphone);
 }

i absolutely have no idea how to do that please help

Aucun commentaire:

Enregistrer un commentaire