创星网络[分享知识 传递快乐]

标题: Android Cursor遍历 [打印本页]

作者: luinstein    时间: 2012-12-11 23:20
标题: Android Cursor遍历
  1. public List<PointBean> getAllPoints() {
  2.                 String sql = "select * from points";
  3.                 SQLiteDatabase db = helper.getWritableDatabase();
  4.                 List<PointBean> pointList = new ArrayList<PointBean>();
  5.                 PointBean point = null;
  6.                 Cursor cursor = db.rawQuery(sql, null);
  7.                 while (cursor.moveToNext()) {
  8.                         point = new PointBean();
  9.                         point.setPointName(cursor.getString(cursor
  10.                                         .getColumnIndex("point_name")));
  11.                         point.setLongitude(cursor.getDouble(cursor
  12.                                         .getColumnIndex("longitude")));
  13.                         point.setLatitude(cursor.getDouble(cursor
  14.                                         .getColumnIndex("latitude")));
  15.                         pointList.add(point);
  16.                 }
  17.                 return pointList;
  18.         }
复制代码
from:http://go.cxweb.com.cn/dv03g





欢迎光临 创星网络[分享知识 传递快乐] (http://bbs.cxweb.com.cn/) Powered by Discuz! X3