Android??SQLite?????С??
???????????? ???????[ 2013/12/24 16:23:08 ] ????????SQLite Android ?????
?????????????????????????????
?????????????????API???????
ContentValues cv=new ContentValues();
//cv.put("id"??1); //id?????? ???????? ????????
cv.put("name"??"???");
cv.put("age"??"27");
db.insert("mytable"??null??cv);
db.close();
|
??????????????????????
????db.execSQL("insert into mytable(name??age) values(????)"??new Object[]{"???"??"27"});
????db.close();
?????????????????
??????????????????
????????????
????db.execSQL("delete from mytable where id=2"); //???id=2???????
????db.execSQL("delete from mytable where name=?"?? new Object[]{"???"}); //??????????name=??????????
????????????
????db.delete("mytable"??null??null); //?????????????е?????
????db.delete("mytable"??"id=?"??new String[]{"2"}); //????????mytable????? id=2???????
??????????????????
????????????
????db.execSQL("update mytable set name='??'??age='23' where id=2"); //?????idλ ???? ???????
????//db.execSQL("update mytable set name='????·'??age='25' where name=?"??new Object[]{"???"});
????????????
ContentValues cv=new ContentValues();
cv.put("name"??"???");
cv.put("age"??"21");
db.update("mytable"??cv??"id=?"??new String[]{"5"});
|
????????????
Cursor cursor=db.query("mytable"??new String[]{"id"??"name"??"age"}??null??null??null??null??null);
while(cursor.moveToNext()) //????????
{
int idindex=cursor.getColumnIndex("id");
int id=cursor.getInt(idindex);
int nameindex=cursor.getColumnIndex("name");
String name=cursor.getString(nameindex);
int ageindex=cursor.getColumnIndex("age");
String age=cursor.getString(ageindex);
String result=id+" "+name+" "+age;
Log.i("result"??result); //??????
}
|
????????????????
???????ж?????????????
????db.close();
??????
???·???
??????????????????
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