Steps
1. Prepare the SQLite Database
Note: Create or copy a database, open it, and execute the following two SQL statements in sequence (set the current location without an error)
Create Table "Android_metadata" ("locale" Text Default ' Zh_cn ' ) Insert Into "Android_metadata" Values ( ' Zh_cn ' )
2. Put the SQLite database file in the assets folder.
Note: The SQLite database size must be smaller than 1 MB.
3. the android client generates database files.
Code Code highlighting produced by actipro codehighlighter (freeware) http: // Www.codehighlighter.com/--> private sqlitedatabase opendatabase () { Try { // Obtain the absolute path of the dictionary. DB File String databasefilename = database_path + "/" + Database_filename; file dir = New File (database_path ); // If the/sdcard/dictionary directory exists, create this directory. If (! Dir. exists () dir. mkdir (); // If it does not exist in the/sdcard/dictionary directory // The dictionary. DB file is copied from the res \ raw directory // Directory of the SD card (/sdcard/dictionary) If (! ( New File (databasefilename). exists ()){ // Obtains the inputstream object that encapsulates the dictionary. DB file. Inputstream is = Getresources (). openrawresource (R. Raw. dictionary); fileoutputstream fos =New Fileoutputstream (databasefilename ); Byte [] Buffer = New Byte [8192 ]; Int Count = 0 ; // Start copying the dictionary. DB File While (COUNT = is. Read (buffer)> 0 ) {FOS. Write (buffer, 0, Count);} FOS. Close (); is. Close ();} // Open the dictionary. DB file in the/sdcard/dictionary directory Sqlitedatabase database = Sqlitedatabase. openorcreatedatabase (databasefilename, Null ); Return Database ;} Catch (Exception e ){} Return Null ;}
Appendix:
Android Market of science back words-Level 4 edition: http://static.apk.hiapk.com/html/2012/07/719368.html