数据库查询示例
[java] view plain copy public static List<Message> query(ContentResolver resolver) { List<Message> list = new ArrayList<>(); Cursor cursor = resolver.query(MyDataProvider.URI.MESSAGE_CONTENT_URI, null, null, null, null); while (cursor.moveToNext()) { Message msg = new Message(); msg.setDate(cursor.getString(cursor.getColumnIndex("date"))); msg.setContent(cursor.getString(cursor.getColumnIndex("content"))); msg.setId(cursor.getInt(cursor.getColumnIndex("id"))); list.add(0, msg); } return list; }新闻热点
疑难解答