Android Cursor遍歷
阿新 • • 發佈:2019-01-11
public List<PointBean> getAllPoints() { String sql = "select * from points"; SQLiteDatabase db = helper.getWritableDatabase(); List<PointBean> pointList = new ArrayList<PointBean>(); PointBean point = null; Cursor cursor = db.rawQuery(sql, null); while (cursor.moveToNext()) { point = new PointBean(); point.setPointName(cursor.getString(cursor .getColumnIndex("point_name"))); point.setLongitude(cursor.getDouble(cursor .getColumnIndex("longitude"))); point.setLatitude(cursor.getDouble(cursor .getColumnIndex("latitude"))); pointList.add(point); } return pointList; }