Android?????????洢????SQLite?????
???????????? ???????[ 2014/6/23 13:31:54 ] ????????Android SQLite ?????
????// ===========sql????????SQLite?????================================
public void insert() {
db.execSQL("insert into person(name?? phone?? money) values(??? ??? ?)"??
new Object[] { "????"?? "18666"?? 6000 });
db.execSQL("insert into person(name?? phone?? money) values(??? ??? ?)"??
new Object[] { "С??"?? "18666"?? 6000 });
db.execSQL("insert into person(name?? phone?? money) values(??? ??? ?)"??
new Object[] { "???"?? "18666"?? 6000 });
}
public void delete() {
db.execSQL("delete from person where name = ?"?? new Object[] { "????" });
}
public void update() {
db.execSQL("update person set money = 10000 where name = ?"??
new Object[] { "С??" });
}
public void query() {
// ?α?????????????????????????resultSet??????
Cursor c = db.rawQuery("select * from person"?? new String[] {});
while (c.moveToNext()) {
String name = c.getString(c.getColumnIndex("name"));
String phone = c.getString(c.getColumnIndex("phone"));
System.out.println(name + ";" + phone);
}
}
|
????// ==============???????api??SQLite?????????======================
/**
* api-insert data to table
*/
public void insertApi() {
ContentValues cv = new ContentValues();
cv.put("name"?? "???");
cv.put("phone"?? 15666);
cv.put("money"?? 630);
long id = db.insert("person"?? null?? cv);
System.out.println(id);
}
/**
* api-delete data from table
*
* @return the number of rows affected
*/
public int deleteApi() {
int affectedNum = db.delete("person"?? "name=?"?? new String[] { "С??" });
return affectedNum;
}
/**
* api-update
*/
public void updateApi() {
ContentValues contentValues = new ContentValues();
contentValues.put("name"?? "С??");
contentValues.put("money"?? "10");
// return the number of rows affected
db.update("person"?? contentValues?? "name=?"?? new String[] { "???" });
}
public void queryApi() {
Cursor cursor = db.query("person"?? new String[] { "phone"?? "money" }??
null?? null?? null?? null?? null);
while (cursor.moveToNext()) {
String phone = cursor.getString(cursor.getColumnIndex("phone"));
String money = cursor.getString(cursor.getColumnIndex("money"));
System.out.println(phone + "##" + money);
}
}
|
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
Android???????????????Щ???????????Android????????????????????????Щ??Android ??????????????????????????APP?????android???????????????Android App ?????????Android Unit Test ?????Android?????????Robolectric3.0????(?)Android??????????????Android Studio???????????Android????MySQL????????????????Android MVP???????Android ?????????ActiveAndroid??дAndroid??????????????????????Android????????Java??????????Android????????Java8Java / Android ????????????????Щ??
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????