0

I would like to run an android method with specific time(like every 5 sec). Here is code, I want to run with time intervals.

shipDB = this.openOrCreateDatabase("shipDB", SQLiteDatabase.CREATE_IF_NECESSARY, null);
                String query = "select *from ShopList";
                Cursor c = shipDB.rawQuery(query, null);
                c.moveToFirst();
                do{
                    String Item = c.getString(c.getColumnIndex("name"));

                    /* Add current Entry to results. */ 
                 results.add(Item);
                }while(c.moveToNext());
                 this.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, results));

How can i do it??

Adn
  • 29
  • 1
  • 3
  • 6
  • Use a timer: http://developer.android.com/reference/java/util/Timer.html – Robert Harvey Mar 19 '13 at 03:42
  • [Example for Timer](http://stackoverflow.com/questions/4597690/android-timer-how). – Rahul Mar 19 '13 at 03:44
  • If all your doing is getting data from a database and want to make sure it's up to date, you can use a `CursorLoader`. http://developer.android.com/reference/android/content/CursorLoader.html – yarian Mar 19 '13 at 03:45
  • @yarian Actually, you're right. Can you give any other reference? – Adn Mar 19 '13 at 04:59
  • @Adn http://stackoverflow.com/questions/12356462/android-cursor-loader – yarian Mar 19 '13 at 17:05

0 Answers0