Android 資料儲存之SQLite

2021-09-07 02:31:40 字數 943 閱讀 5682

android在執行時整合了sqlite , 所以每個android應用程式都可以使用sqlite資料庫。

我們通過sqlitedatabase這個類的物件操作sqlite資料庫,而且不需要身份驗證。

資料庫存放的位置:data/data/《專案資料夾》/databases/,檢視資料庫》

例項:

public class mainactivity extendsactivity  }); /** 建立表 */createtable.setonclicklistener(newonclicklistener()  }); /** 插入資料 */insertdata.setonclicklistener(newonclicklistener()  }); /** 更新資料 */updatedata.setonclicklistener(newonclicklistener()  }); /** 查詢資料 */selectdata.setonclicklistener(newonclicklistener() , "id=?", new string , null, null, null); string name=null; while(cursor.movetonext()) toast.maketext(mainactivity.this, "查詢結果name為:"+name, 1000).show(); } }); /** 刪除資料 * */deletedaata.setonclicklistener(newonclicklistener() ); toast.maketext(mainactivity.this, "資料刪除成功", 1000).show(); } }); } }

使用getwritabledatabase或getreadabledatabase的時候,資料庫才會鏈結,通過execsql執行sql語句。

Android之資料儲存

概述 1.android中包含5中資料儲存方式 sharedpreferences儲存資料。contentprovider儲存 檔案儲存 sqllite資料庫儲存 網路儲存 preference file database 這三種方式分別對應的目錄是 data data package name s...

android之資料儲存之SQLite

sqlite開源輕量級資料庫,支援92 sql標準,主要用於嵌入式系統,只佔幾百k系統資源此外,sqlite 不支援一些標準的 sql 功能,特別是外來鍵約束 foreign key constrains 巢狀 transcaction 和 right outer join 和 full outer...

Android 資料儲存之Files

android中一共提供了四種資料儲存方式 shared preferences主要用於系統配置資訊的儲存,比如使用者登入時,輸入了使用者名稱密碼,下次登入時保留這一次的輸入內容。files就是把需要儲存的東西都存到檔案中,需要時,則通過讀取這個檔案來獲取。sqlite是乙個開源的關聯式資料庫,可以...