On Mar 4, 11:49 pm, Justin Allen Jaynes <[email protected]> wrote: > I'm building a dictionary application with 135,000 word entries (words > only). My raw file must have been too large (1.5 meg), because I got > this error: > > D/asset (909): Data exceeds UNCOMPRESS_DATA_MAX (1424000 vs 1048576) > > I've searched for this error with very few relevant hits. It seemed to > mean I could not open an uncompressed file over a meg. So I then split > the file into two smaller files and ran my code on both of them. It > worked out fine. My total application size is 3 meg installed. > > My code is: > public void onCreate(SQLiteDatabase database) { > database.execSQL("CREATE TABLE " + DATABASE_TABLE + " (wordid > INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, word VARCHAR);"); > > Scanner fileScanner = new > Scanner(myContext.getResources().openRawResource(R.raw.wordlist)); > while ( fileScanner.hasNextLine() ) { > String wordFromFile = fileScanner.nextLine(); > database.execSQL("INSERT INTO words (word) VALUES ('" + > wordFromFile + "');"); > } > fileScanner = new > Scanner(myContext.getResources().openRawResource(R.raw.wordlist2)); > while ( fileScanner.hasNextLine() ) { > String wordFromFile = fileScanner.nextLine(); > database.execSQL("INSERT INTO words (word) VALUES ('" + > wordFromFile + "');"); > } > > } > > However, when the application is first run, it takes several MINUTES to > initialize the database in this way. Is there a way (like a copy > command, as found in, say, postgresql, or a restore of a database file) > to copy data from a raw file, and can such a method be accessed from the > SDK so that standard first-run procedures can correctly set up the > database? I have been unable to locate such a luxury. I am seeking to > speed up this data populating process. > > First question: how can I speed up my database population?
Pre-populating it and building the database file into your app, as the other response suggested, is probably the best way to do it. However, if you decide to populate the database when your app is first run, you might still be able to speed it up by wrapping the whole process inside an SQLite transaction. Otherwise, it creates a separate transaction for each query, which is slow. That's according to the SQLite Optimization FAQ (http://web.utk.edu/~jplyon/sqlite/ SQLite_optimization_FAQ.html), although that FAQ is out of date by now so maybe it's no longer true. Jesse --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

