We often need to use databases with prepared content, such as dictionaries. This requires loading existing database files and storing them in assets or raw, copy to the internal space of the program when the program is running:/data/package/my_app/databases. For details, refer to here.
However, this has a disadvantage. When the file is large, it will take a long time, and the user will inevitably be a little worried.
We can use HACK to save the copy process as follows:
1. Place the database file (such as MYDB. db) in PROJECT/libs/armeabi/and change it to libMYDB. db. so (note that "lib" must be added before ").
2. Open it in this way:
[Java]
DATABASE_PATH = "/data/" + packageName + "/lib /";
SQLiteDatabase db = SQLiteDatabase. openDatabase (DATABASE_PATH + libMYDB. db. so, null, SQLiteDatabase. OPEN_READONLY | SQLiteDatabase. NO_LOCALIZED_COLLATORS );
In this way, the database can be used after the program is installed. The principle is to disguise the database file as a lib library file, during installation, the program will automatically copy to/data/package/lib/, saving our own copy process.
Currently, I have tested the read operation and the write operation is still to be tested.
(Full text)
From herbert's knowledge base