一、SqliteOpenHelper
1.SqliteOpenHelper类小demo:
思路:
DBHelper类
1>DBHelper extends SQLiteOpenHelper
2>声明成员变量:数据库版本、新建表
3>复写onCreate()、onUpgrade()
4>在onCreate()中db.exexSQL(sql);
MyDBActivity:增、删、改、查
public void CreateTable() {
db = dbHelper.getWritableDatabase();
String sql = "create table if not exists TestUsers"
+ "(id int primary key,name varchar,sex varchar)";
try {
db.execSQL(sql);
} catch (Exception e) {
// TODO: handle exception
Log.i("err", "");
}
}
2.完整源码: https://github.com/Way123Ne/android/tree/master/SqliteOpenHelperDemo
1.启动AVD(已root)找到data目录下data文件夹下对应的应用程序包名,
找到savedata.xml文件,真机需root查看
2.以xml文件保存Map数据类型Map(key,value)
3.特点:保存轻量级数据
4.完整源码: https://github.com/Way123Ne/android/tree/master/SharedPreferencesDemo