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 WebView Cookie Problem
  • java.lang.NoSuchMethodError: No interface method sort(Ljava/util/Comparator;) exception in sorting arraylist android
  • Why DialogFragment can't be an inner class?
  • What causes jobb tool to throw FAT Full IOException?
  • Android - Opening the email application?
  • in-app billing android return authentication is required when try to subscribe to product
  • Related posts:

    Android when ViewPager insert as Child get error android.view.ViewGroup.jumpDrawablesToCurrentState(...
    Get the field value with a Cursor
    Android Studio local path doesn't exist
    new to android need to understand “?android:attr/actionBarSize”
    What is your workflow for testing Cloud Code on Parse?
    using onTouch and onCreateContextMenu at the same time
  • Android 2.3 Visualizer - Trouble understanding getFft()
  • Saving ArrayLists in SQLite databases
  • Android data binding ObservableList behaviour issue
  • Didn't find class “com.google.firebase.provider.FirebaseInitProvider”
  • IllegalStateException - Fragment support library
  • Read font size from Settings
  • 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 +"'");
    

    Thanks

    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.