Android教程之android資料庫程式設計

2021-09-22 04:58:37 字數 1161 閱讀 9464

由於android內建了sqlite資料庫!

sqlite本身就是乙個很小型的資料庫!

資料庫儲存的位置在data/data/《專案資料夾》/databases/ 

1:建立資料庫context.createdatabase(string name,int version ,int mode,curso***ctory factory)

如果建立不成功則丟擲filenotfoundexception異常

sqlitedatabase database=

this

.openorcreatedatabase(

"database.db"

,     

mode_private,      

newcurso***ctory()     

}); 

2:開啟已經存在的資料庫context.opendatabase(string file,curso***ctory factory);

如果我們要實現開啟不存在的資料庫就建立它,**如下:

//建立乙個名為:database的資料庫,字尾為.db    

sqlitedatabase database=

this

.openorcreatedatabase(

"datebase.db"

,     

mode_private,      

null

);     

//也可以這樣寫   

try      

catch

(filenotfoundexception e)      

catch

(filenotfoundexception e)      

}     

3:關閉資料庫

//千萬不要忘記關閉資料庫哦    

database.close(); 

4:刪除指定資料庫

this

.deletedatabase(

"database.db"

);  

5:執行sql命令使用:sqlitedatabase.execsql(string sql);

其他東西後面有時間的時候在補充!

Android教程之android資料庫程式設計

由於android內建了sqlite資料庫!sqlite本身就是乙個很小型的資料庫!資料庫儲存的位置在data data 專案資料夾 databases 1 建立資料庫context.createdatabase string name,int version int mode,curso ctor...

Tkinter使用教程之Android測試工具

實戰解析 from tkinter import from tkinter import ttk def create window 建立視窗 root tk root.title androidtool root.geometry 360x282 root.resizable 0,0 標題行功能 ...

Android的開發之 無線除錯android裝置

這段時間一直在忙啊忙,公司要做機頂盒,沒有人做過,無奈之下只能邊研究邊做,經過乙個多月的時間,測試版本終於出來了。今天給大家介紹下使用adb命令無線除錯除錯安卓應用,那有些人肯定會問,無線除錯有啥用啊,連著線除錯挺好的。那如果線壞了那,你會說在換乙個,那如果電腦usb插口壞了那,當然可以換個電腦,哈...