Often we need to use some pre-made content of the database, such as dictionaries, which will load the existing database files, usually put them in assets or raw, when the program is run, copy to the internal space of the program,
But this has a drawback, when the file is larger will take a long time, users will inevitably a little anxious.
We can do this hack to save the copy link:
1 Put the database files (such as mydb.db) to project/libs/armeabi/renamed LibMYDB.db.so (Note that "Lib" must be added before).
2 Open in such a way:
Database_path = "/data/data/" + PackageName + "/lib/"; null, Sqlitedatabase.open_readonly | sqlitedatabase.no_localized_collators);
----------------------------------------------------
//Note the path PrivateString Database_path = "/data/data/" + "Com.cjoan.www.xiaohua" + "/lib/"; Privatesqlitedatabase studb;//Database LoadStudb = sqlitedatabase.opendatabase (Database_path + "libxiaohua.db.so",NULL, Sqlitedatabase.open_readonly|sqlitedatabase.no_localized_collators); Cursor Rawquery= Studb.rawquery ("SELECT * from article where id=?",NewString[] {"1" }); System.out.println (Rawquery.movetofirst ()); if(Rawquery.movetofirst ()) String title= rawquery.getstring (1);
Android disguises the database as so file