public void getdatabase() { sqlite = new SQLiteCityManager(getActivity(), "weatherdb", null, 1); db = sqlite.getWritableDatabase(); Cursor cursor = db.query("coolWeather", null, null, null, null, null, null); HomePageFragment.mcmb.clear(); while (cursor.moveToNext()) { int _id = cursor.getInt(cursor.getColumnIndex("_id")); cityname = cursor.getString(cursor.getColumnIndex("cityname")); imageurl = cursor.getString(cursor.getColumnIndex("imageurl")); weather = cursor.getString(cursor.getColumnIndex("weather")); temp = cursor.getString(cursor.getColumnIndex("temp")); Log.i( "TAG", _id + " @@@@@@@@_id-" + " cityname-" + cityname + " imageurl-" + imageurl + " weather-" + weather + " temp-" + temp); setCityManagerEntity(); } }
/** 删除数据库 */ public void deletedata() { sqlite = new SQLiteCityManager(getActivity(), "weatherdb", null, 1); db = sqlite.getWritableDatabase(); db.delete("coolWeather", "_id = " + 2, null); }