title: Query for retrieving data between two timings from sqlite databse?
body: <p>How to retrieve the data between two timing from sqlite according to the current timing.</p>
  
  <p>I use this query but it doesn't works</p>
  
  <pre><code> final Cursor cView = db.rawQuery("SELECT * FROM proname WHERE FromTiming &gt;= time('now', 'localtime')\n" + "" +
              "AND ToTiming &lt;= time('now', 'localtime')\n" + " ORDER BY FromTiming LIMIT 1", null);
  </code></pre>
  
  <p>My oncreate is :</p>
  
  <pre><code>public static final String[] titles = new String[]{"Akilam 360","Ipadikku Idhayam",
          "Palsuvai Thoranam"};
  
  
  
  public static  final String[] fromtime = new String[]{"5:00:00","07:00:00","09:00:00"};
  
  public static  final String[] totime = new String[]{"6:59:59","08:59:59","10:59:59"};
  
  
  public static final Integer[] images = {R.drawable.akilam_360,
          R.drawable.ipadikku_idhayam, R.drawable.palsuvai_thoranam};
  
  ListView listView;
  List&lt;Program&gt; rowItems;
  int  iImageId;
  String sTitle,sFrom,sTo ;
  SQLiteDatabase db;
  
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.dbcon);
  
  
  
      Calendar c = Calendar.getInstance();
  
      int seconds = c.get(Calendar.SECOND);
      int minutes = c.get(Calendar.MINUTE);
      int hour = c.get(Calendar.HOUR_OF_DAY);
      String time = hour+":"+minutes+":"+seconds;
  
      timer = (TextView) findViewById(R.id.timer);
      timer.setText(time);
  
  
  
  
      db =openOrCreateDatabase("MukilProgram", Context.MODE_PRIVATE,null);
      db.execSQL("CREATE TABLE IF NOT EXISTS proname(ImageID INTEGER,Title TEXT,FromTiming INTEGER,ToTiming INTEGER);");
  
      rowItems = new ArrayList&lt;Program&gt;();
      for (int i = 0; i &lt; titles.length; i++) {
          Program item = new Program(images[i], titles[i],fromtime[i],totime[i]);
          rowItems.add(item);
      }
  </code></pre>
  
  <p>My retrieving part:</p>
  
  <p>final Cursor cView = db.rawQuery("SELECT * FROM proname WHERE FromTiming >= time('now', 'localtime')\n" + "" +
                  "AND ToTiming &lt;= time('now', 'localtime')\n" + " ORDER BY FromTiming LIMIT 1", null);
          if (cView.getCount() > 0) {</p>
  
  <pre><code>        sImageID = new ArrayList&lt;String&gt;();
          sName = new ArrayList&lt;String&gt;();
          iFrom = new ArrayList&lt;String&gt;();
          iTo = new ArrayList&lt;String&gt;();
  
  
  
          while (cView.moveToNext()) {
  
              sImageID.add(cView.getString(0));
              sName.add(cView.getString(1));
              iFrom.add(cView.getString(2));
              iTo.add(cView.getString(3));
  
              //     sQuantity.add(cView.getString(2));
              SQliteAdapter sqliteadapter = new SQliteAdapter(Databaseconnection.this, sImageID, sName,iFrom,iTo);
              listView.setAdapter(sqliteadapter);
          }
  
      }
  </code></pre>
  
  <p>This query is working but I am not getting any result or error please help me in writing correct query for this.</p>