1、繼承sqliteopenhelper類
public
class
myopenhelper
extends
sqliteopenhelper
@override
public
void
oncreate(sqlitedatabase db)
@override
public
void
onupgrade(sqlitedatabase arg0, int arg1, int arg2)
}
2、獲取資料庫例項
myopenhelper oh=new myopenhelper(getcontext());
sqlitedatabase db=oh.getwritabledatabase();
3、資料庫增刪查改操作
(1)插入
public
void
insertdatebase()
api插入
contentvalues cv=new contentvalues();
cv.put("name", "ppa");
cv.put("money", 16000);
long id = db.insert("person", null, cv);
(2)更新
public
void
updatedatabase());
}
api更新
contentvalues cv=new contentvalues();
cv.put("money", 16005);
int num = db.update("person", cv, "name=?", new
string);
(3)刪除
public
void
deletedatabase()
api刪除
int num = db.delete("person", "name=?", new string);
(4)查詢
public void select() );
while (cursor.movetonext())
}
api查詢
cursor cursor = db.query("person", new
string, "name=?", new
string, null, null, null);
1、繼承sqliteopenhelper類
public class myopenhelper extends sqliteopenhelper
@override
public void oncreate(sqlitedatabase db)
@override
public void onupgrade(sqlitedatabase arg0, int arg1, int arg2) }1
2345
6789
1011
1213
1415
1617
2、獲取資料庫例項
myopenhelper oh=new myopenhelper(getcontext());
sqlitedatabase db=oh.getwritabledatabase();12
3、資料庫增刪查改操作
(1)插入
public void insertdatebase()12
3456
api插入
contentvalues cv=new contentvalues();
cv.put("name", "ppa");
cv.put("money", 16000);
long id = db.insert("person", null, cv);12
345(2)更新
public void updatedatabase());
}1234
5api更新
contentvalues cv=new contentvalues();
cv.put("money", 16005);
int num = db.update("person", cv, "name=?", new string);12
34(3)刪除
public void deletedatabase()12
3456
api刪除
int num = db.delete("person", "name=?", new string);12
(4)查詢
public void select() );
while (cursor.movetonext())
}123456
78910
11api查詢
cursor cursor = db.query("person", new string, "name=?", new string, null, null, null);
12
建表主鍵自增 Oracle建表,建主鍵,自增
oracle建表,建主鍵,自增 建表 create table test id number 4 not null primary key,name varchar2 25 序列 create sequence test sequence increment by 1 每次增加幾個 start wi...
oracle建表設定主鍵自增
首先建立一張表 create table member memberid number primary key,membermail varchar2 20 not null,membername varchar2 20 not null,memberpassword varchar2 20 然後,...
oracle建表並主鍵自增
oracle建表,並設主鍵自增 建立使用者表 create table user info t id integer not null user id varchar 50 user name varchar 50 user password varchar 50 user varchar 20 u...