I've a problem with the query to mananage the sqlite database in android.
this is a sample method :
public Cursor selectID( Integer id){
// query code for select
}
But all the query method that i see , not allow me to manage an integer parameter, or anything else except a String parameter. Usually i use the rawQuery method:
for example :
db.rawQuery("Select id from dbName where id = ?", new String[] {id});
But that, as i said , is not possible with Integer or other parameter ( for example
new Integer[] {id};
How i can do to solve my problem?
Use String.valueOf(id)
which will return the String representation of your int.
http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#valueOf(int)
So your statement will look like:
db.rawQuery("Select id from dbName where id = ?", new String[] {String.valueOf(id)});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With