On click of 'getDetails' button I want to get details using substring from a column.
There is no error in my code but I feel there should be some wrong in the db.query.
Can some one sort it out?
public void getDetails(View v)
{
String s1=name.getText().toString();
String sub1=s1.substring(0,s1.indexOf(s1));
String s3= vivzHelper.getData(sub1);
Message.message(this,s3);
}
public String getData(String name) {
SQLiteDatabase db = helper.getWritableDatabase();
String[] columns = {VivzHelper.NAME};
String[] selectionArgs = {name};
Cursor cursor= null;
cursor = db.query(VivzHelper.NAME, columns, VivzHelper.NAME + "=?", null, null, null, null, null);
StringBuffer buffer = new StringBuffer();
while(cursor.moveToNext())
{
int indexID=cursor.getColumnIndex(VivzHelper.UID);
int nameID=cursor.getInt(indexID);
int accountNameIDX=cursor.getColumnIndex(VivzHelper.NAME);
String accountName=cursor.getString((accountNameIDX));
buffer.append(nameID+" "+ accountName+"/n");
}
return buffer.toString();
}