I want to view my database table through textview, but no data is displayed when i click the button, any help would be appreciated
employee class
onclicklistner
{
Intent viewallemp=new Intent(getApplicationContext(),ViewallEMP.class);
startActivity(viewallemp);
}
ViewallEMP class
TextView viewallemp=(TextView)findViewById(R.id.showtextView1);
DBhandle dbhandle=new DBhandle(this);
dbhandle=dbhandle.open();
dbhandle.getEMPData();
String empdata=dbhandle.getEMPData();
viewallemp.setText(empdata);
database class
public String getEMPData() {
String[] columns = new String[] { EMP_ID, EMP_NAME, EMP_DOB, EMP_ADDR, EMP_PHONE };
Cursor c = ourDatabase.query(EMPINFO_TABLE_NAME, columns, null, null, null,
null, null);
String result = "";
int iRow = c.getColumnIndex(EMP_ID);
int iName = c.getColumnIndex(EMP_NAME);
int iDOB = c.getColumnIndex(EMP_DOB);
int iADDR = c.getColumnIndex(EMP_ADDR);
int iPHONE = c.getColumnIndex(EMP_PHONE);
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
result = result + c.getString(iRow) + " " + c.getString(iName)
+ " " + c.getString(iDOB) + " " + c.getString(iADDR)+ " " + c.getString(iPHONE) + "\n";
}
following data is stored in database
Aucun commentaire:
Enregistrer un commentaire