android - Infinity loop. Reading data from database and comparing them to with an if statment -


my english little rusty, try explain want do.

i have database , 5 rows in it. trying this:

  1. read n rows database.
  2. assign data database variables
  3. check if variables belongs condition
    if(((szerokosc<=a)&&(szerokosc>=b)) && ((dlugosc>=c)&&(dlugosc<=d)))
  4. if yes, display (opis)
  5. if not, display(brak danych)
  6. if end of rows go first
  7. if there exists next row, go it,

i want on , on again;

public void onlocationchanged(location location) {     showlocation(location);     showadditionalinfo(location);     if(savedlocation == null)     savedlocation = locationmanager.getlastknownlocation(locationmanager.gps_provider);     databasehelper zb = new databasehelper(getapplicationcontext());     double szerokosc = location.getlatitude();     double dlugosc = location.getlongitude();     cursor k = zb.dajcos();     string lokalizacja = "jestes na: ";     while(k.movetonext())     {         nazwa = k.getstring(0);         szmax= k.getdouble(1);         szmin= k.getdouble(2);         dlmin= k.getdouble(3);         dlmax= k.getdouble(4);         opis = k.getstring(5);         a=szmax;         b=szmin;         c=dlmin;         d=dlmax;          if(k.movetonext()==false){k.movetofirst();}     }     if(((szerokosc&lt;=a)&&(szerokosc&gt;=b)) && ((dlugosc&gt;=c)&&(dlugosc&lt;=d)))     {         lokalizacja =nazwa+opis;     }     else     {         lokalizacja ="brak danych";     }     tvlokalizacja.settext(lokalizacja); } 

this public cursor dajcos()

public cursor dajcos()  {      string[] kolumny={"nazwa","szmax","szmin","dlmin","dlmax","opis"};      sqlitedatabase db = getreadabledatabase();      cursor kursor = db.query("obiekty", kolumny, null, null, null, null, null);      return kursor; } 

i dont know how explain better. try describe in way.

in database have 5 records each of them include coordinates. example: position corresponds coordinates second row , want display in "zone1", move ten meters away , position don't match coordinates in row want display "no data", move fifteen meters away fourth row coordinates match position , display in "zone2".

i hope understand mean , me. thank you.

i have loop:

k.movetofirst();         //iterate on rows         (int = 0; < k.getcount(); i++) {             nazwa = k.getstring(0);         szmax= k.getdouble(1);            szmin= k.getdouble(2);            dlmin= k.getdouble(3);         dlmax= k.getdouble(4);         opis = k.getstring(5);          a=szmax;             b=szmin;             c=dlmin;             d=dlmax;              wypisz +=i+nazwa+"-"+a+"-"+opis+"\n";             tvbaza.settext(wypisz);              k.movetonext();              } 

loop execute 5 times because have 5 rows in database. want change execute on , on again.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -