I am developing a dictionary app where users can download vocabulary through an API. But I don't want to make my app look empty until they searched for their first word. So I have managed to arrange all the words with their definitions as string array and thought of displaying them as a list.
The problem here is that as I stored vocabulary with their definitions the string array gets too long that the android studio wont allow me to store such a huge number of vocabulary items in the resource array. Also by doing so the app size might increase a lot. I saw many offline dictionaries that work without downloading data on their first run. How did they achieve that ?
Any idea is appreciated. Thank you
You should create and Offline database like the SQlite database. Storing Big amounts of data in the string array is not an efficient way here.
This link may help you.
Or you can search for other offline databases.
For offline dictionary, you can store data into CSV file then import CSV file into your android studio project, either you can directly read content from it or you can insert into sqlite.
Related
My android application supports 3 languages(english, korean, russian) and I'm planning to support more of it.
because of app characteristics, it has millions of line(translation) in each strings.xml file. so the size of the all string.xml files exceeds 1MB.
I think it's too large.
Is there a way to localize android app without using values/strings.xml?
or...trim the size of my app?
One possible way to do this would be to put the data strings in an SQLite database instead of putting them all in strings-xx resource files. I once worked on a project with tons of strings in different languages. The solution we came up with was to put only the UI-related strings in the strings-xx resource files, and the data strings in SQLite tables. This reduced the APK size significantly.
By UI-related strings I mean those like screen titles, button/widget texts, constant strings with format parameters and so on. Data strings would be those that are dependent on or received in an API response.
You can implement custom resource loading using a more space efficient file format than xml, but I doubt its worth the effort.
If you want to do this, check for the current locale to decide which resources to load:
getResources().getConfiguration().locale
I'm trying to make a simple Hangman game for android (without using any libraries like libGdx) and first problem I encountered was this. I don't know where should I put all the words that I made for my game. Should I make it a simple txt file or XML resource file? Should I put that file into new directory or into values directory?
I'll need to read that data file and put all words to String array. File will not be modified during game.
Any advice would be very welcome.
I think it would be best to make use of android's built in sqlite database. If you would use a text file you would have to parse all of the data into an array then pull out a random record to use for your game. If you use a database you are able to pull a random record from the database with a single query. Sqlite would make more efficient use of your resources.
When I google "how to make a dictionary", it gives me a great measure of the explanation of "make", which is very helpful. But I need something else, so I put this question here.
I want to make a small project. I want to make a dictionary with java or android. But I don't know how should I organize the words. I have considered a JSON file, a XML file or I can also simply output all the words as ojbects into a file. Could anyone please give me some adivce?
Assuming that you want to be able to read (quickly) values from your dictionary, and maybe update values or create new values then I suggest that you store your dictionary in a Database. For a simple Java database I suggest that you use an embedded Derby Database.
see http://db.apache.org/derby/
I want to implement a website word search (user searches about a word and gets the sentences which include the word from the specific website) in java MYSELF (without using lucandra,solr,nutch,... I mean),till now I can get content (text,not the source code) of website with the help of jsoup,but I don't know how to index the datas in the database,I searched google to understand about algorithms which well known indexers such as solr use,I have understood some things such as using inverted list or hashtable,... but they are so in general,I want to know exactly what should I do?
I want to use cassandra as my db,so I read about cassandra secondry indexing,but I have to know more about it,is this really what I should focus on?
I'm writing a tool to analyze stock market data. For this I download data and then save all the data corresponding to a stock as a double[][] 20*100000 array in a data.bin on my hd, I know I should put it in some database but this is simply performance wise the best method.
Now here is my problem: I need to do updates and search on the data:
Updates: I have to append new data to the end of the array as time progresses.
Search: I want to iterate over different data files to find a minimum or calculate moving averages etc.
I could do both of them by reading the whole file in and update it writing or do search in a specific area... but this is somewhat overkill since I don't need the whole data.
So my question is: Is there a library (in Java) or something similar to open/read/change parts of the binary file without having to open the whole file? Or searching through the file starting at a specific point?
RandomAccessFile allows seeking into particular position in a file and updating parts of the file or adding new data to the end without rewriting everything. See the tutorial here: http://docs.oracle.com/javase/tutorial/essential/io/rafs.html
You could try looking at Random Access Files:
Tutorial: http://docs.oracle.com/javase/tutorial/essential/io/rafs.html
API: http://docs.oracle.com/javase/6/docs/api/java/io/RandomAccessFile.html
... but you will still need to figure out the exact positions you want to read in a binary file.
You might want to consider moving to a database, maybe a small embedded one like H2 (http://www.h2database.com)