Android sqlite cursor的遍历

时间:2014-04-28 10:07:40   收藏:0   阅读:1390

查询并获得了cursor对象后,用while(corsor.moveToNext()){}遍历,当corsor.moveToNext()方法调用,如果发现没有对象,会返回false

bubuko.com,布布扣
    public List<MMImage> getAll() {
        List<MMImage> list = new ArrayList<MMImage>();
        Cursor c = null;
        try {
            c = database.query(TABLE, null, null, null, null, null, null);
            while (c.moveToNext()) {
                MMImage mmImage = getMMImageFromCursor(c);
                list.add(mmImage);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (c != null) {
                c.close();
            }
        }
        return list;
    }
bubuko.com,布布扣

 

Android sqlite cursor的遍历,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!