0

I am trying to build dictionary app(actually it is a modification of google SearchableDictionary sample), whose source of words and their definitions is very big, around 5MB. I tried many ways and using many formats and it still cant run properly on android. Sqlite database should be the best solution, I have built it and its size is 10MB(tried building it both before runtime and during runtime). The main problem is the size of the definitions, but I have seen some other applications have managed to do this. It might be that there are some file size limits built into android system, but anyways if they werent it all takes so much to search and run queries in this sqlite database.

What am I doing wrong? BTW: It HAS to be offline dictionary (download definitions max 1 time).

Problem in a nutshell:

word -definition 
word2 -definition2...

Stored in a 10MB sqlite database (tried loading it from assets), not working. With some hacks (loading it manually with eclipse DDMS tool) it is working but terribly slow.

1
  • How did you try to load it from assets? Where's the code? Where is the logcat output when it fails? Commented Dec 8, 2010 at 20:18

6 Answers 6

2

Are you loading the database from the Assets folder? If yes, then that's your problem. There is a file size limit on what is in the assets folder (1mb I believe).

You have two options:

  1. Split up your database into multiple 1mb files
  2. Create a webservice. Have your application call the webservice which in turn downloads the database to your Android device. OR create a webservice API that your application uses to get data on as it needs it basis.
Sign up to request clarification or add additional context in comments.

1 Comment

Downloading the database or its contents on installation sounds good, as that way you won't waste space on the device with a delivered copy in the .apk file plus the working copy, but only have the working copy. But of course then you need a web server to download it from, you can no longer use the android market.
1

I have achieved by zipping the database and unzipping it into external caching direcotry (SD Card). you can look at the sample code here - http://www.android.manutech.mobi/2011/03/how-to-manage-sqlite-databases-with.html

Comments

1

Rename it to something like "databasename.mp3" or any media format. It won't be compressed by the package manager and therefore you can use it just like you need.

Comments

0

Have you tried compressing the file? If the data is just raw text I bet it'll compress to smaller than 1 MB.

2 Comments

How could I compress the file and how does that help? It only reduces the package size, but I have to use it uncompressed to be able to search for definitions.
You compress it, put it in assets, then when your app gets installed uncompress it and put it in the DB directory.
0

1) Store a compressed version of only the words using the GZIP. (this will be very small only about 350k, and must be pre-sorted)

2) Load the list into a:

new ArrayList<String>();

3) Use a binarySearch to find the word

.binarySearch

4) When you need a definition, call an API like this with the word

http://services.aonaware.com//DictService/DictService.asmx/Define?word=aardvark

5) parse the resulting XML

Comments

0

10M file is just way too small to worry about. It didn't work, it might be because of the way of opening the database file. By default, Android read database file from ://data/data/PACKAGENAME/databases/DATABASENAME.

A simple solution could be: 1) compress the db file to res/raw/DATABASE.zip, 2) then unzip it to //data/data/PACKAGENAME/databases/.

You can get sqlite android demo code from here: http://www.cs.dartmouth.edu/~campbell/cs65/lecture15/lecture15.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.