Android开发数据库Sqlite1
1.数据库的创建
DatabaseHelper.java
package com.xrj.databasedemo; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import androidx.annotation.Nullable; public class DatabaseHelper extends SQLiteOpenHelper { /* context 上下文 name 数据库名称 factory 游标工厂 version 版本号 */ public DatabaseHelper(@Nullable Context context) { super(context, Constants.DATABASE_NAME, null, Constants.VERSION_CODE); } @Override public void onCreate(SQLiteDatabase db) { } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } }
Constants.java
package com.xrj.databasedemo; public class Constants { public static final String DATABASE_NAME = "first.db"; public static final int VERSION_CODE = 1; }
MainActivity.java
package com.xrj.databasedemo; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //创建数据库 DatabaseHelper helper = new DatabaseHelper(this); helper.getWritableDatabase(); } }
在monitor导出first.db,导入可视化
相关推荐
Nostalgiachild 2020-11-13
韩伟佳 2020-10-09
wuleihenbang 2020-09-16
zzqLivecn 2020-07-09
chenjinlong 2020-06-10
yinbaoshiguang 2020-06-09
sgafdsg 2020-06-04
ustcrding 2020-06-03
chenjinlong 2020-06-03
AndroidGA 2020-06-01
安辉 2020-05-27
绿豆饼 2020-05-26
CNETNews 2020-05-26
xilove0 2020-05-12
绿豆饼 2020-05-12
ChainDestiny 2020-05-07
doomvsjing 2020-05-07
hqulyc 2020-05-05
lyccsu 2020-04-30