I'm looking at loading files with the datasaver module and some of my files are fairly large. My concern is that Android will shut down an application if it locks the main thread for too long and I'm dealing with some files that are fairly large.
I'm wondering how others are dealing with this?
Comments
If you will divide somehow you can init, search and get to the information much more faster.
I don't know what kind of file is it but let's suppose that it is a dictionary file just to give an example:
-You can divide the dictionary file into smaller files and give a prefix like
af_xxx.txt
go_xxx.txt
jp_xxx.txt
and so on according to word list in each files...
So in this case you can make a very simple index like the word "Gideros" will in the file which is starting with "go" prefix.
Of course as i wrote have no idea what is the purpose of your big file, but if you will share more information maybe some other ideas can be invented
Some of these sets of questions are controlled by me, but my users will also be able to create sets of questions/answers which can be used to compete against one another.
I could put some arbitrary limit and not allow files over a certain size (which I may end up doing for memory purposes), but in terms of locking the main application thread I think that will be hit before memory usage especially on lower end Android devices.
What I would like to do is spin up a background thread that does the file loading and present the user with a loading spinner or such.
If I were creating a native Android application I would do this with an IntentService
http://developer.android.com/training/run-background-service/create-service.html
I'm wondering if there is a way to do something similar with Gideros where I can spin up and control a background thread that can provide me with some type of callback mechanism once it has completed.
First the class that does the actual loading..
This is just a very basic example and you could do more processing when each line is read, checking the first character for example to determine if the line is a question, or an answer, etc.
Does it help at all?
Likes: hotbuttered
So in the data file that gets loaded.. Any line beginning with * is a question. The first line after a question is the correct answer and subsequent lines are false answers. This gives a good base for a multi choice question system and it accommodates as many or as few choices per question automatically.
As you iterate through the lines of text you can use some simple rules to generate the list of questions like this..
Anyway, I better get back to what I'm supposed to be doing
Likes: hotbuttered, rolfpancake
Thanks. As always you are very helpful. I haven't been logged in for a few days, but this is great stuff.