How can i pass intger to a rawquery in sqlite for android. Here its not taking g and s into query. Please guide.
int g, s;
Cursor cur3 = database2.rawQuery("select max(UnixTimeStamp) from Quote where EmoticonID=%d and SubCategoryID=%d" ,new String [] {g,s});
All parameter places should be designated with ?. The parameters to the query are always string nontheless, so nothing special about the integers. This should work for you:
Cursor cur3 = database2.rawQuery("select max(UnixTimeStamp) from Quote where EmoticonID=? and SubCategoryID=?" ,new String [] {String.valueOf(g),String.valueOf(s)});
Parameter in your query needs to be string so please convert these parameters into string and write your query as follows.
Use String.valueOf();
Cursor c = db.rawQuery(SELECT max(UnixTimeStamp)
FROM Quote
WHERE EmoticonID ='"+d+"' AND SubCategoryID ='"+ s +"'");
Thanks
Cursor cur3 = database2.rawQuery("select max(UnixTimeStamp) from Quote where EmoticonID="
+ g + " and SubCategoryID = " + s + " ");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.