我怎么能intger传递给rawquery SQLite中的机器人。 在这里,它不是以G和s转换查询。请指导。
INT G,S;
光标cur3 = database2.rawQuery(选择马克斯(UnixTimeStamp)的报价,其中EmoticonID =%d到SubCategoryID =%D,新的String [] {G,S});
解决方案
所有参数的地方应该用指定的?这些参数的查询总是字符串nontheless,所以没有什么特别的整数。这应该为你工作:
光标cur3 = database2.rawQuery(选择马克斯(UnixTimeStamp)的报价,其中EmoticonID =?和SubCategoryID =?,新的String [] {将String.valueOf(G),字符串.valueOf(多个)});
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)});