3
I am new in Android development, I am using Sqlite as a bank. I need to make a SELECT, and return the values of three columns of my table. Then I need to set the attributes of my object with the return values of this SELECT .
1- I own an object called Imagecolor, as 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 bank is like this:
I want to make a SELECT and return the values of RED, GREEN and BLUE.
my method that makes SELECT and returns an object of type Imagecolor and that:
public ColorImage SelectedColor(String nome){
ColorImage color = new ColorImage();
String selectQuery = "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 don’t know what’s wrong. Someone knows what’s wrong?
Does not return value, do not know what is wrong.
– Mik3i4a5