SQLite資料庫建立 增刪改查

2021-08-17 11:16:01 字數 609 閱讀 4101

建立資料庫

public class myopenhelpter extends sqliteopenhelper

/** 呼叫時機:第一次建立資料庫時,oncreate會執行**/

@override

public void oncreate(sqlitedatabase db)

@override

public void onupgrade(sqlitedatabase db, int oldversion, int newversion)

}在dao類裡實現增刪改查

//新增資料的方法

public void add(emp emp)

}//查詢

public listselect()

//關閉資料庫物件的方法

database.close();

return us;

}//執行刪除操作

public void delete()

//修改資料的方法
//查詢資料的方法: query("表名",... )

public listselect()

return stu; }

SQLite資料庫的增刪改查

1 資料庫的curd 1 public class persondao 1213 增刪改查 1415 16 往資料庫新增一條資料 17 18public void add string name,string phone 27 關閉資料庫 釋放資料庫的鏈結 28db.close 29 30 3132...

SQLite資料庫的增刪改查

1 資料庫的curd 1 public class persondao 1213 增刪改查 1415 16 往資料庫新增一條資料 17 18public void add string name,string phone 27 關閉資料庫 釋放資料庫的鏈結 28db.close 29 30 3132...

sqlite 增刪改查

公共 private sqlitedatabase database getwritabledatabase 1.新增新資料 database.execsql insert into tablename id,name,passname,time values new object 2.刪除資料,多...