Android(安卓)sqlite cursor的遍历
16lz
2021-01-24
查询并获得了cursor对象后,用while(corsor.moveToNext()){}遍历,当corsor.moveToNext()方法调用,如果发现没有对象,会返回false
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; }
更多相关文章
- PackageManagerService(Android5.1)深入分析(四)安装应用
- android之GSON解析JSON
- Android(4.X)学习笔记
- 【Android】通过软引用实现图片缓存,防止内存溢出
- 用PC应用程序通过USB读写Andriod里面的数据
- Android控件开发之Gallery
- Android开发经验总结
- Android(安卓)获取网络时间
- android apk编译