I have a working application that uses a database and SQLiteAssetHelper . The database file (sql.sqlite) is encrypted (sql.sqlite.zip) and placed in the assets / databases folder.
The program works fine. And when you start to the second / third / fourth ... time it starts quickly. But if I make a “forced stop” followed by “clear data”, then run it again, and then when I run it (view logs), I see the error “unknown error (code 14): could not open the database "... but then I wait a few seconds and it all loads and works great.
The log is as follows:
W/SQLiteAssetHelper(18393): could not open database SQL.sqlite - unknown error (code 14): Could not open database W/SQLiteAssetHelper(18393): copying database from assets... W/SQLiteAssetHelper(18393): extracting file: 'sql.sqlite'... W/SQLiteAssetHelper(18393): database copy complete I/SQLiteAssetHelper(18393): successfully opened database SQL.sqlite
So it looks like he was somehow trying to find the database, failed, crashed, and then fixed it himself. So my question is: how could I avoid a clumsy start and a few seconds of delay?
EDIT: My first database link in my code ...
public class Globals extends Application { Custom_SQLiteAssetHelper db; public void onCreate() { super.onCreate(); db = new Custom_SQLiteAssetHelper(this); cursor = db.get_first_species_common_name();
and i have ...
public class Custom_SQLiteAssetHelper extends SQLiteAssetHelper { public Custom_SQLiteAssetHelper(Context context) { super(context, "SQL.sqlite", null, 1); } public Cursor get_first_species_common_name() { SQLiteDatabase db = getReadableDatabase(); SQLiteQueryBuilder querything = new SQLiteQueryBuilder();
android sqlite
Mick
source share