// 查询数据库信息条数的方法 public int Date_count() { // 获取数据库的读取权限 SQLiteDatabase db = DB_SQL.getReadableDatabase(); // 查询全部信息 Cursor cursor = db.query("mynotepad_date", null, null, null, null, null, null); // int count = cursor.getCount(); int count = 0; while (cursor.moveToNext()) { count++; } return count; }
public List<Mynotepad_Model> Date_look() { datelist = new ArrayList<Mynotepad_Model>(); // 获取对数据库的读写权限 SQLiteDatabase db = DB_SQL.getReadableDatabase(); // 查询全部信息 Cursor cursor = db.query("mynotepad_date", null, null, null, null, null, null); while (cursor.moveToNext()) { // 查看是否有下一条 true false; Mynotepad_Model note = new Mynotepad_Model( cursor.getInt(cursor.getColumnIndex("_ID")), cursor.getString(cursor.getColumnIndex("_TITLE")), cursor.getString(cursor.getColumnIndex("_WEATHER")), cursor.getString(cursor.getColumnIndex("_TIME")), cursor.getString(cursor.getColumnIndex("_BODY"))); datelist.add(note); } return datelist; }