1、连接Android自带的数据库
import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; public class DBHelper extends SQLiteOpenHelper { // 数据库默认名字 public static final String db_name= "familyBill2.db"; //用于创建bill表——记录收入 public static final String CREATE_IN = "create table bill (" + "id integer primary key autoincrement, " +"date text," + "type text, " + "money text)"; public DBHelper(Context context, int version) { super(context, db_name, null, version); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(CREATE_IN); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } }
2、设计目录页面