1、扩展类SQLiteOpenHelper
xxSQLiteHelper extends SQLiteOpenHelper
public xxSQLiteHelper(Context context,String name,CursorFactory factory,int version){
surper(context,name,null,1);
}
onCreate(SQLiteDatabase db)
onUpgrade(SQLiteDatebase db,int newversion,int oldversion)
Cursor c //查询结果的指针
c.getString(c.getColumIndex("name"))
2、使用
xxSQLiteHelper xx=new xxSQLiteHelper (this);
SQLiteDatabase db=xx.getWritableDatabase();
db.insert.....
db.query()
db.close();
3、展现:SimpleCorsorAdapter sa=new SimpleCorsorAdapter(this,layout,c,new String[]{"name","sex"},new int[]{R.id.iname,R.id.isex});
要求表中必须有一列,_id Integer primary key autoincrement
刷新listView :
sa.changeCorsor(c);
插一嘴:在内部类中访问可能会变的变量是不被允许的,所以,都用final常量限定