freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

基于android平臺(tái)的天氣軟件開(kāi)發(fā)畢業(yè)論-資料下載頁(yè)

2025-06-07 13:41本頁(yè)面
  

【正文】 ()。 ()。 } (insert ========= OK )。 } 23 } 當(dāng)控制臺(tái)顯示最后一句話的時(shí)候,就表示所有數(shù)據(jù)插入成功了 ,一共 2564 條數(shù)據(jù) 。 接下來(lái)要進(jìn)行的是創(chuàng)建 city 表,然后插入數(shù)據(jù), 這里 將默認(rèn)的城市設(shè)置為 北京 ,城市碼是 101010100 。 詳細(xì) 過(guò)程 不再描述,只給出執(zhí)行語(yǔ)句: (create table city(_id int, code varchar(10))。 String sql = INSERT INTO city(_id, code) values(1, 39。10101010039。)。 到這里 , 整個(gè) 數(shù)據(jù)庫(kù)就創(chuàng)建 完成 了。 數(shù)據(jù)庫(kù)名為 panda_weather ,創(chuàng)建的兩張表為 cities 和 city 。 接下來(lái)檢驗(yàn)數(shù)據(jù)庫(kù)創(chuàng)建是否成功,把虛擬設(shè)備運(yùn)行起來(lái),進(jìn)入到命令行提示符下,輸入 adb shell 命令,進(jìn)入到 Android 操作系統(tǒng)中,通過(guò) cd 命令進(jìn)入到存放數(shù)據(jù)庫(kù)的目錄,輸入命令 sqlite3 panda_weather 后,進(jìn)入到數(shù)據(jù)庫(kù)模式下,然后輸入 .schema 命令,查看數(shù)據(jù)庫(kù)中 是否包含 cityes 和 city 兩張表 , 再 用 select * from cities。 和 select * from city。 兩條命令 查看表中的記錄是否正確。 這里, 看到的結(jié)果與插入的一致 , 表示 數(shù)據(jù)庫(kù)創(chuàng)建成功了。 數(shù)據(jù)庫(kù)操作 數(shù)據(jù)庫(kù)創(chuàng)建成功后,就 投入到具體的使用了 。 經(jīng)過(guò)分析可以知道, 對(duì)數(shù)據(jù)庫(kù)的操作主要包括數(shù)據(jù)庫(kù)的初始化、由城市名得到對(duì)應(yīng)的城市碼、設(shè)置默認(rèn)城市碼和得到默認(rèn)城市碼這樣四個(gè)操作。 代碼如下: public class Database_Tools { // 當(dāng)前上下文 private Context _context。 // 構(gòu)造函數(shù) public Database_Tools(Context context) { _context = context。 } private String dbPath = data/data/。 // 數(shù)據(jù)庫(kù)路徑 private String dbName = panda_weather。 // 數(shù)據(jù)庫(kù)名稱(chēng) /** * 把數(shù)據(jù)庫(kù)文件復(fù)制到指定目錄 */ public void init() { 24 try { String DATABASE = dbPath + dbName。 File dir = new File(dbPath)。 // 如果目錄已經(jīng)存在,則返回 if (()) { return。 } // 創(chuàng)建目錄 ()。 // 如果數(shù)據(jù)庫(kù)文件不存在,執(zhí)行復(fù)制數(shù)據(jù)庫(kù)文件 if (!(new File(DATABASE).exists())) { // 獲得封裝 文件的 InputStream對(duì)象 InputStream is = ().open(panda_weather)。 FileOutputStream fos = new FileOutputStream(DATABASE)。 // 下面這一段代碼不是很理解,有待研究 byte[] buffer = new byte[8192]。 int count = 0。 // 開(kāi)始復(fù)制 db文件 while ((count = (buffer)) 0) { (buffer, 0, count)。 } ()。 ()。 } } catch (Exception e) { ()。 } } /** * 由城市名得到對(duì)應(yīng)的城市碼 * @param city * @return */ public String getCityCode(String city) { Database_Helper dbHelper = new Database_Helper(_context, panda_weather)。 SQLiteDatabase db = ()。 Cursor cursor = null。 try { cursor = (cities, new String[] { _id, code, city }, 25 city=?, new String[] { new String((), UTF8) }, null, null, null)。 } catch (UnsupportedEncodingException e) { ()。 } String code = 。 while (()) { code = ((code))。 } ()。 // 關(guān)閉數(shù)據(jù)庫(kù) return code。 } /** * 得到數(shù)據(jù)庫(kù)中的默認(rèn)城市 Code * @return */ public String getDefaultCode() { Database_Helper dbHelper = new Database_Helper(_context, panda_weather)。 SQLiteDatabase db = ()。 Cursor cursor = null。 try { cursor = (city, new String[] { _id, code }, _id=?, new String[] { 1 }, null, null, null)。 } catch (Exception e) { ()。 } String city = 。 while (()) { city = ((code))。 (query + city)。 } ()。 ()。 // 釋放數(shù)據(jù)庫(kù)資源 = city。 // 給默認(rèn)數(shù)據(jù)庫(kù)賦值 return city。 } /** * 設(shè)置數(shù)據(jù)庫(kù)中的默認(rèn)城市 Code */ 26 public void setDefaultCode(String code) { Database_Helper dbHelper = new Database_Helper(_context, panda_weather)。 SQLiteDatabase db = ()。 ContentValues values = new ContentValues()。 (code, code)。 (city, values, _id = ?, new String[] { 1 })。 // 更新默認(rèn)城市 ()。 } } 在代碼中 給出 了 數(shù)據(jù)庫(kù)路徑 data/data/、數(shù)據(jù)庫(kù)名 panda_weather 和執(zhí)行具體操作的 四個(gè)函數(shù)。 在對(duì)數(shù)據(jù)庫(kù)進(jìn)行操作前,同前面創(chuàng)建數(shù)據(jù)庫(kù)時(shí)講到的一樣,需要獲得一個(gè) SQLiteOpenHelper 對(duì)象,然后才能進(jìn)行操 作 ,這里不再 描述 。 四個(gè)函數(shù)的函數(shù)名分別為 init、 getCityCode、 getDefaultCode、setDefaultCode 。 init 函數(shù)執(zhí)行的數(shù)據(jù)庫(kù)的 初始化工作,軟件在 加載 的時(shí)候檢查數(shù)據(jù)庫(kù)是否存在,如果不存在,就將數(shù)據(jù)庫(kù)文件拷貝到指定的目錄 ,如果檢測(cè)到存在,則直接返回。getCityCode 函數(shù)是在搜索時(shí)候用到的, 操作的對(duì)象是 cities 表, 也是在使用中用到的最多的函數(shù)。搜索時(shí),由輸入的城市名,搜索對(duì)應(yīng)的城 市碼,然后將結(jié)果返回,如果沒(méi)有搜索到,則提示城市不存在 。 函數(shù) getDefaultCode 和 setDefaultCode 操作的是 city 表, 獲得默認(rèn)的城市碼和更新數(shù)據(jù)庫(kù)設(shè)置新的默認(rèn)城市碼。 這樣,對(duì)數(shù)據(jù)庫(kù) 方面 的編程就完成了。 用戶界面 及 操作 加載 界面 加載 界面 Load_Activity, 程序開(kāi)始運(yùn)行的時(shí)候加載這個(gè)頁(yè)面 ,使用的布局文件是 。 頁(yè)面的內(nèi)容很簡(jiǎn)單, 在頁(yè)面中共設(shè)置了 3 個(gè) TextView,分別顯示學(xué)校中文 全稱(chēng),英文簡(jiǎn)稱(chēng)和版權(quán)信息 ,顯示內(nèi)容在 文件中進(jìn)行了聲明,這里使用的時(shí)候直接引用 。 以 布局文件為例, 代碼如下: ?xml version= encoding=utf8? 27 LinearLayout xmlns:android= android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical LinearLayout android:layout_width=fill_parent android:layout_height=wrap_content android:orientation=horizontal TextView android:layout_width=fill_parent android:layout_height=wrap_content android:textSize=12pt android:textStyle=bold android:layout_marginTop=80dp android:gravity=center_horizontal android:text=@string/siasU/ /LinearLayout TextView android:layout_width=fill_parent android:layout_height=wrap_content android:textSize=20pt android:textStyle=bold android:layout_marginTop=60dp android:gravity=center_horizontal android:text=@string/sias/ LinearLayout android:orientation=vertical android:layout_width=fill_parent android:layout_height=wrap_content android:layout_marginTop=100dp TextView android:text=@string/ab android:layout_width=fill_parent android:layout_height=wrap_content android:gravity=center_horizontal/ /LinearLayout /LinearLayout 在 整個(gè) 界面中使用 LinearLayout 線性布局 ,方向?yàn)榇怪狈较颉?所以,在界面中的控件從上到下依次顯示。設(shè)置的主要屬性為:居中顯示、控件之間間隔等。 28 在 中, 設(shè)置布局文件為 ,代碼為 : setContentView()。 這是程序的加載界面,所以,界面加載的時(shí)候要為應(yīng)用程序 做一些準(zhǔn)備工作, 包括前面提到的數(shù)據(jù)庫(kù)初始化工作,默認(rèn)城市的天氣數(shù)據(jù)下載工作 等 。數(shù)據(jù)庫(kù)的初始化 : // 初始化,轉(zhuǎn)移數(shù)據(jù)庫(kù)文件 ()。 初始化數(shù)據(jù)庫(kù)之后,就要進(jìn)行默認(rèn)城市天氣數(shù)據(jù)的下載工作。 這里為設(shè)置了一個(gè)定時(shí)器,在加載界面顯示 800 毫秒之后開(kāi)始數(shù)據(jù)的下載 ,具體的操作放在一個(gè)任務(wù)里面,在定時(shí)器到了之后開(kāi)始執(zhí)行任務(wù) 。 下載的過(guò)程放在一個(gè) Service 里面,代碼如下: TimerTask task = new TimerTask(){ public void run() { intent = new Intent(, )。 (code, ())。 (intent)。 while(true){ if(() != 0){ (0)。 break。 } } } }。 下載過(guò)程執(zhí)行過(guò)后,判斷下載是否成功 ,然后 關(guān)閉 Serv
點(diǎn)擊復(fù)制文檔內(nèi)容
畢業(yè)設(shè)計(jì)相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1