I am working on pre-installed database and using SqliteAssetHelper library for that.
This is my db code
public class DBController extends SQLiteAssetHelper {
private static final String DATABASE_NAME = "user.db";
private static final int DATABASE_VERSION = 1;
private final String TABLE_NAME = "User";
public DBController(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public ArrayList<UserData> getAllUserData() {
ArrayList<UserData> data_list = new ArrayList<>();
try {
// open database to query
SQLiteDatabase mySqliteDb = getWritableDatabase();
} catch (Exception e) {
Log.e("exception", "" + e);
}
close();
return data_list;
}
}
Error: Missing databases/user.db file (or .zip, .gz archive) in assets, or target folder not writable
and when I change my code to SQLiteDatabase mySqliteDb = getReadableDatabase();
I am getting android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database error.
I search for the problem and mostly everyon saying check your db present inside databases folder or not.
I tried using zip also still no luck. I guess I am missing something.
Aucun commentaire:
Enregistrer un commentaire