7pupu / android-studio

android-studio
0 stars 0 forks source link

180807 #2

Open wotupset opened 6 years ago

wotupset commented 6 years ago
public class DBHelper extends SQLiteOpenHelper{
    private final static String DATABASE_NAME="demo.db";  //資料庫檔案名稱
    private final static int DATABASE_VERSION=1;   //資料庫版本
    public DBHelper(Context context){
        super(context,DATABASE_NAME,null,DATABASE_VERSION);
    }
    public void onCreate(SQLiteDatabase db){
        final String INIT_TABLE="create table "+TABLE_NAME+"("+_ID+" integer primary key autoincrement,"+NAME+" char,"+TEL+" char,"+EMAIL+" char)";
        db.execSQL(INIT_TABLE);
    }
    public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion){
        final String DROP_TABLE="drop tabel if exists "+TABLE_NAME;
        db.execSQL(DROP_TABLE);
        onCreate(db);
    }
}

http://hsingjungchen.blogspot.com/2017/07/androidsqlite.html?m=1

http://mropengate.blogspot.com/2015/12/android-ch7-sqlite-stetho.html?m=1