E/SQLiteAssetHelper: Couldn't open databases/brodsky.db for writing (will try read-only):
com.readystatesoftware.sqliteasset.SQLiteAssetHelper$SQLiteAssetException: Missing databases/databases/brodsky.db file (or .zip, .gz archive) in assets, or target folder not writable
at android.content.res.AssetManager.openAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:336)
at android.content.res.AssetManager.open(AssetManager.java:310)
at com.readystatesoftware.sqliteasset.SQLiteAssetHelper.copyDatabaseFromAssets(SQLiteAssetHelper.java:436)
at com.readystatesoftware.sqliteasset.SQLiteAssetHelper.createOrOpenDatabase(SQLiteAssetHelper.java:400)
at com.readystatesoftware.sqliteasset.SQLiteAssetHelper.getWritableDatabase(SQLiteAssetHelper.java:176)
at com.readystatesoftware.sqliteasset.SQLiteAssetHelper.getReadableDatabase(SQLiteAssetHelper.java:254)
at rodionova.lyubov.brodsky.db.PoemsProvider.query(PoemsProvider.java:40)
at android.content.ContentProvider.query(ContentProvider.java:1140)
at android.content.ContentProvider$Transport.query(ContentProvider.java:262)
at android.content.ContentResolver.query(ContentResolver.java:506)
public class PoemsDbHelper extends SQLiteAssetHelper {
private static String DB_NAME = "databases/brodsky.db";
private static final int DB_VERSION = 1;
public PoemsDbHelper(Context context) {
super(context, DB_NAME, null, DB_VERSION);
}
}
和一个类ContentProvider,因为它也是在日志中的错误中指定的
公共类PoemsProvider扩展ContentProvider{private static final UriMatcher URI_MATCHER=new UriMatcher(UriMatcher.no_match);private static final int peams=1;private static final int peams=2;private static final int FACTS=3;private static final int profection=4;
static {
URI_MATCHER.addURI(PoemsContract.AUTHORITY, "poems", POEMS);
URI_MATCHER.addURI(PoemsContract.AUTHORITY, "poems/#", POEM);
URI_MATCHER.addURI(PoemsContract.AUTHORITY, "facts", FACTS);
URI_MATCHER.addURI(PoemsContract.AUTHORITY, "biography", BIOGRAPHY);
}
private PoemsDbHelper poemsDbHelper;
@Override
public boolean onCreate() {
poemsDbHelper = new PoemsDbHelper(getContext());
return true;
}
@Nullable
@Override
public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection,
@Nullable String[] selectionArgs, @Nullable String sortOrder) {
SQLiteDatabase db = poemsDbHelper.getReadableDatabase();
switch (URI_MATCHER.match(uri)) {
case POEMS:
if (TextUtils.isEmpty(sortOrder)) {
sortOrder = PoemsContract.Poems.COLUMN_ID + " DESC";
}
return db.query(PoemsContract.Poems.TABLE_NAME,
projection,
selection,
selectionArgs,
null,
null,
sortOrder);
case POEM:
String id = uri.getLastPathSegment();
if (TextUtils.isEmpty(selection)) {
selection = PoemsContract.Poems._ID + " = ?";
selectionArgs = new String[]{id};
} else {
selection = selection + " AND " + PoemsContract.Poems._ID + " = ?";
String[] newSelectionArgs = new String[selectionArgs.length + 1];
System.arraycopy(selectionArgs, 0, newSelectionArgs, 0, selectionArgs.length);
newSelectionArgs[newSelectionArgs.length - 1] = id;
selectionArgs = newSelectionArgs;
}
case FACTS:
if (TextUtils.isEmpty(sortOrder)) {
sortOrder = PoemsContract.Facts.COLUMN_ID + " DESC";
}
return db.query(PoemsContract.Facts.TABLE_NAME,
projection,
selection,
selectionArgs,
null,
null,
sortOrder);
case BIOGRAPHY:
if (TextUtils.isEmpty(sortOrder)) {
sortOrder = PoemsContract.Biography.COLUMN_ID + " DESC";
}
return db.query(PoemsContract.Biography.TABLE_NAME,
projection,
selection,
selectionArgs,
null,
null,
sortOrder);
default:
return null;
}
}
而不是私有静态字符串DB_NAME=“databases/brodsky.db”;
您应该使用私有静态字符串DB_NAME=“brodsky.db”;
SQliteAssetHelper在自述文件中包括以下内容:-
public class MyDatabase extends SQLiteAssetHelper {
private static final String DATABASE_NAME = "northwind.db";
private static final int DATABASE_VERSION = 1;
public MyDatabase(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
}
assets/databases/northwind.db
简介 Laravel 可以用 seed 类轻松地为数据库填充测试数据。所有的 seed 类都存放在 database/seeds 目录下。你可以任意为 seed 类命名,但是更应该遵守类似 UsersTableSeeder 的命名规范。Laravel 默认定义的一个 DatabaseSeeder 类。可以在这个类中使用 call 方法来运行其它的 seed 类从而控制数据填充的顺序。 编写 See
//内容提供程序代码 公共静态最终字符串授权=“com.battlestarMathematica.stayfresh.pantryprovider”; //游标加载程序代码
我已经花了几个小时阅读产品分支中的0和1。请在Firebase数据库有经验的人帮助我:(
我看到了许多类似问题的答案,人们说为了获得组合框中加载的项目的值,需要使用 但这种东西不起作用…… 这是我所拥有的…… 我从表中选择了Code1和Code2,我希望能够显示Code1,当被选中时,我希望能有Code2的值,但对于displayMember和ValueMember,我看不到任何结果。 编辑:这是我的所有代码: 暗淡的行=dt. Load(com. Ex 错误提示:表达式不产生值 编辑
我有一个有两列的表,一个是string,另一个是double Type。例如, 我正在尝试读取所有的值,并将它们加载到中 我在读取表数据方面没有任何问题,但不能按我的要求将它们放入HashMap中。 我编写了一个示例代码来从两个不同的数组(string和double)填充一个HashMap,但仍然无法处理HashMap的值部分,它是一个数组。 任何建议我如何处理HashMap的值部分,它是一个数组