连接本地的数据库
package com.example.bookkeeping; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.widget.Toast; public class MyDatabaseHelper extends SQLiteOpenHelper { public static final String CREATE_LIST="create table zhangben(" +"id integer primary key autoincrement," +"盈亏 text," +"原因 text," +"金额 text," +"时间 text)"; private Context mContext; public MyDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version){ super(context,name,factory,version); mContext=context; } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(CREATE_LIST); Toast.makeText(mContext, "创建成功", Toast.LENGTH_SHORT).show(); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } }