You need to write moveToFirst();
before fetching data from cursor, like below,
public String getSum(String code)
{
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(TABLE_OWNER, new String[] { KEY_SUM }, KEY_CODE + "=?", new String[] { code }, null, null, null, null);
if ( cursor.getCount() > 0 )
{
cursor.moveToFirst(); // Add this line
String data = cursor.getString(cursor.getColumnIndex("data"));
return data;
}
return null;
}