android 数据库初体验

public class DatabaseHelper extends SQLiteOpenHelper{
    private static  final String  DATABASE_NAME="NOTE.db";
    private static  final int  DATABASE_VERSION=1;
    private static  final String TABLE_NAME="NOTE";
    private static  final  String CreateTable="CREATE table NOTE(" +
            "id int primary key," +
             "node TEXT NOT NULL,"+
            "created INTEGER," +
            "modifi)"  ;
    public DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null,DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
             sqLiteDatabase.execSQL(CreateTable);
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
        sqLiteDatabase.execSQL("DROP TABLE IF EXISTS "+TABLE_NAME);
        onCreate(sqLiteDatabase);
    }
}
 成功创建数据库 。

使用 adb shell  sqlite3 note.db  进入数据库  .schema note  显示表结构

.databases 显示数据库

你可能感兴趣的:(android)