Android??SQLite?????С??
???????????? ???????[ 2013/12/24 16:23:08 ] ????????SQLite Android ?????
????Android??????????SQLiteDatabase?????????????Щ??????????API?????????????????????????(Create)?????(Retrieve)??????(Update)?????(Delete)????????Щ????????CRUD??
????SQLite ????? NULL??INTEGER??REAL(????????)??TEXT??BLOB(?????????)??5???????????
????SQLite ?????????????λ??/data/data/package-name/databases ?????
????????????????????????SQLiteOpenHelper??????????MySqlHelper.java???????????SQLiteOpenHelper?????????
package com.alpha.sqlite;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
public class MySqlHelper extends SQLiteOpenHelper {
public MySqlHelper(Context context?? String name?? CursorFactory factory??
int version) {
super(context?? name?? factory?? version);
// TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
//??????????????? 3?????????
//primary key ???????? ?????????о?????????л??е????????????????е????С?????????л???г?????????
db.execSQL("create table mytable(id integer primary key autoincrement??name text??age text)");
}
@Override
public void onUpgrade(SQLiteDatabase arg0?? int arg1?? int arg2) {
// TODO Auto-generated method stub
}
}
|
????????????????????? SQLiteOpenHelper ?????? MySqlHelper ?????????????????? ??onCreate?????? ????????????Ρ?
private MySqlHelper mysql;
private SQLiteDatabase db;
mysql=new MySqlHelper(MainActivity.this??"mydb"??null??1);
db=mysql.getReadableDatabase(); //??????????????
|
????getReadableDatabase()??????????????????????д???????????????????洢??????????????????????????????????????????????
????getWritableDatabase()??????????????????????д???????????????????洢?????????????????????????
??????????????getReadableDatabase()???????????????
??????
???·???
??????????????????
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