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

正文內容

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

2025-06-06 10:39本頁面
  

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