luinstein 发表于 2012-12-11 23:20:50

Android Cursor遍历

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;
        }from:http://go.cxweb.com.cn/dv03g
页: [1]
查看完整版本: Android Cursor遍历