我从数据库中检索信息,这些信息都存在指针内。现在我需要去指针中的每个项目来检索信息然后显示在页面上。
Cursor c = mDbHelper.fetchSpot(15);
startManagingCursor(c);
double lat = Double.parseDouble(c.getString(c.getColumnIndexOrThrow(ParkingSpotDBAdapter.KEY_LAT)));
double lng = Double.parseDouble(c.getString(c.getColumnIndexOrThrow(ParkingSpotDBAdapter.KEY_LNG)));
String name = c.getString(c.getColumnIndexOrThrow(ParkingSpotDBAdapter.KEY_ADDRESS));
我用fecthAllSpots()方法可以在指针中返回很多项目,如何在指针中的项目里检索信息呢?
for (int i = 0; c.moveToPosition(i); i++)
{
//...
}
while(c.moveToNext()){
...
}
你都得到数据了查起来还不方便吗
while(c.moveToNext()){
double lat = Double.parseDouble(c.getString(c.getColumnIndexOrThrow(ParkingSpotDBAdapter.KEY_LAT)));
double lng = Double.parseDouble(c.getString(c.getColumnIndexOrThrow(ParkingSpotDBAdapter.KEY_LNG)));
String name = c.getString(c.getColumnIndexOrThrow(ParkingSpotDBAdapter.KEY_ADDRESS));
}