由于您的解决方案,我已经完成了我的应用程序,我来到这里是关于我当前应用程序的最后一个问题,我创建的数据库我无法访问它,我读到它在 android 系统中,所以我应该怎么做才能访问数据库并导出它?
public class DBAdapter {
private static final String DATABASE_NAME = "bd";
private static final int DATABASE_VERSION = 3;
private final Context context;
private static DatabaseHelper DBHelper;
private SQLiteDatabase db;
static String SqlCreate = "CREATE TABLE password(id INTEGER, name TEXT, password TEXT)";
public DBAdapter(Context ctx) {
this.context = ctx;
DBHelper = new DatabaseHelper(context);
}
public void onOpen(SQLiteDatabase db) {
db = DBHelper.getWritableDatabase();
// super.onOpen(db);
if (!db.isReadOnly()) {
// Enable foreign key constraints
db.execSQL("PRAGMA foreign_keys=ON;");
}
}
private static class DatabaseHelper extends SQLiteOpenHelper {
DatabaseHelper (Context context) {
super(context,DATABASE_NAME,null,DATABASE_VERSION);
}
public void onCreate(SQLiteDatabase db) {
try {
db.execSQL(DATABASE_CREATE1);
db.execSQL(DATABASE_CREATE3);
db.execSQL(SqlCreate);
// db.execSQL(DATABASE_CREATE2);
}
catch(SQLException e) {
e.printStackTrace();
}
}