You may use this following code actually it is rough but plz check it out
db = openOrCreateDatabase("sms.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
Cursor cc = db.rawQuery("SELECT * FROM datatable", null);
final ArrayList<String> row1 = new ArrayList<String>();
final ArrayList<String> row2 = new ArrayList<String>();
if(cc!=null) {
cc.moveToFirst();
startManagingCursor(cc);
for (int i=0; i<cc.getCount(); i++) {
String number = cc.getString(0);
String message = cc.getString(1);
row1.add(number);
row2.add(message);
final EditText et3 = (EditText) findViewById(R.id.editText3);
final EditText et4 = (EditText) findViewById(R.id.editText4);
Button bt1 = (Button) findViewById(R.id.button1);
bt1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.button1:
et3.setText(row1.get(count));
et4.setText(row2.get(count));
count++;
break;
default:
break;
}
}
});
cc.moveToNext();
}