Android SQLite rawquery parameters

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});

  • Android - alternative for OpenCV?
  • Setting Roboto font in TextView - xml
  • How to get center of map for v2 android maps?
  • remove ColorFilter / undo setColorFilter
  • How to use ThreeTenABP in Android Project
  • Setting camera image size in Android
  • Related posts:

    android - java - WeakReferences with an ArrayList?
    debug android : connect to sqlite db on phone
    How to start activity when user clicks a notification?
    Android - how to force child to override parent method that has code
    Replacing the standard Android H264 software encoder with an ffmpeg based one
  • How to insert extra elements into a SimpleCursorAdapter or Cursor for a Spinner?
  • Optimization of AndEngine game
  • Google Mobile Ads and Kindle Fire
  • How can I add a fragment to a ViewPager? addView crashes my app
  • Custom ViewPager rendering issue on certain devices:
  • How to center align text in a tab bar in Android
  • 3 Solutions collect form web for “Android SQLite rawquery parameters”

    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 +"'");


    Cursor cur3 = database2.rawQuery("select max(UnixTimeStamp) from Quote where EmoticonID="
                                     + g + " and SubCategoryID = " + s + " ");
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.