I am trying to get text from getText method from database and display the string in the TextView. But I have no idea why it is not working.
Database:
public String getType(String search){
String type="";
String searchTypeQuery="SELECT * FROM "+ DatabaseData.TABLE_NAME + " WHERE "+ DatabaseData.NAME+ " LIKE '%" +search +"%'";
SQLiteDatabase db=this.getWritableDatabase();
Cursor cursor=db.rawQuery(searchTypeQuery,null);
// looping through all rows
if (cursor.moveToFirst()) {
do {
String objectName = cursor.getString(cursor.getColumnIndex(DatabaseData.TYPE));
type=objectName;
} while (cursor.moveToNext());
}
cursor.close();
db.close();
// return the list of records
return type;
}
Main:
if (database.getType("Sample")=="A"){
textview.setText("Type");
}
I tried this "textview.setText(database.getType("Sample"));" and it worked. But when i try the above code it doesn't work.