I'm new to Android development, I'm using SQLite as a database. I need to do a SELECT, and return the values of three columns in my table . Then I need to set the attributes of my object with the return values of this SELECT .
I have an object called ImageColor , according to the code below:
public class ColorImage {
private int RedColor;
private int GreenColor;
private int BlueColor;
private int Id;
private String Nome;
//Getters e Setters
}
2 - My table in the database looks like this:
IwanttodoaSELECTandreturnthevaluesofRED,GREENandBLUE.
MymethodthatdoestheSELECTandreturnsanobjectoftypeImageColorandthis:
publicColorImageSelectedColor(Stringnome){ColorImagecolor=newColorImage();StringselectQuery="SELECT red, green, blue FROM COLOR WHERE nome =" + nome;
SQLiteDatabase banco = this.getWritableDatabase();
Cursor cursor = banco.rawQuery(selectQuery, null);
color.setRedColor(cursor.getInt(0));
color.setGreenColor(cursor.getInt(1));
color.setBlueColor(cursor.getInt(2));
return color;
}
But it's not working, I do not know what's wrong. Does anyone know what's wrong?