Including string search in multiple choice questions in ODK Collect - android

The question is based on using the ODK Collect on an Android platform:
I am working with multiple choice questions type where the choices are being sourced from a .csv file. Thus far it is a standard ODK procedure, however, I want to include a string search option in the question due to the large number of options in the .csv. The string search is to reduce the number of choices the participant has to go through, and hence the search needs to be performed multiple times.
What is the best way to go about this?
My thoughts so far: Work with the ODK Collect source code to "inject" a string search option into the respective activity windows.

You can use the search function in the "appearance column", and example is given below
search('locationset','matches','countryid',1)
where locationset is the name of csv file, and countryid is a column in the csv, 1 is the value that i want it to search
I've attached an image of a form, to have a better idea. Hope this helps

Related

Android, Store large amount of text (HTML) and search through them

I am making a framework in order to easily "appify" books.
This framework will need to automatically detect chapter and heading to make a table of contents. The idea is to also be able to easily search through the text and find what you are looking for.
Now what I still need to figure out is:
how to store the data in such a way that I can easily detect the chapters and heading
and still be able to search through the text.
The text that is stored needs to be formatted, so I thought I would store them as HTML or Markdown (which will be translated to HTML). I don't think it would be very searchable if the text is in HTML.
P.S. it does not have to be HTML if there are other more efficient ways to format the text.
Do you really want to do such thing on the device itself?
I can suggest you to use separate sqlite database for every book. With separate tables for table of contents, chapters, summarized keywords of chapters(for faster search) and other service info.
Also here you can find full text search example
Also I recommend you to bring your own sqlite build with your app.
Now lets talk about the main problem of yours - the book scraping.
I have no competency here, I believe this problem is the same as the web sites scraping.
Upd:
Please do not store book contents as HTML, you can store it as markdown for example, it takes less amount of storage, easier to sanitize and you can always apply your styles later

What's the proper way of importing option lists into an Android app?

I have been storing option lists for my Android app in a cloud table. For example, categories like "historical fiction","biography","science fiction", etc. I see the following pros and cons:
Pro:
I can make changes to the list without sending an app update to Google Play
Not normalized - I can use the text in my other data tables instead of a reference ID
Con:
App needs to take time to download from the web each time (or at least check for changes)
English only
I believe the "proper" way to do this is the use the XML resource files. But I need to make sure the selection references correctly with my data. That is, my app needs to understand that "Poetry" and "Poesía" are the same thing.
Is the correct thing to do:
Forget about it since I'll never get to the point where I'm translating my app anyway
Use a string-array and use the index (0...x) to know what the selection is
Use a 2-dimensional string-array with a reference ID in the first column and the text in the second?
If you are handling the category list online, then why not handle the translations online as well. Here is what I would suggest:
In your application options, have a list of supported languages (each in their native translation). These language options should be stored on whatever server application is handling your web requests. Each language is associated with an integer ID that the user does not see, but is stored in the app.
Whenever you issue a web request to get a list of options, include the language id in the message. This will allow you to know what language the user has picked and can use a 2D array or some other structure to handle the conversion to and from the chosen language.
I'm not sure if this helps at all, since I don't know exactly what you are making or how you are designing it, but from the given description, this is an easy and effective course of action.

Best approach for android autocomplete search box

I would like any suggestions on how to implement a fast autocomplete search box on android.
Useful info:
1) Data will be stored locally on phone memory. No database or network should be needed.
2) There is no restriction on the type of file that will be used. Could be simple text file, XML file, or whatever suits best.
3) The file will contain a large amount of records that are distinguished by a unique ID/CODE.
There will be also a human readable name for the record and a text with more info on the record like
CODE: HUMAN_REPRESENTATION: EXTRA_INFO:
AF32 Orange The orange (specifically, the sweet orange) is the fruit of the citrus species Citrus...
AF33 Apple The apple is the pomaceous fruit of the apple tree...
4) The user will type on the text area the HUMAN_REPRESENTATION string he wants, and he will be shown a list of matching records to select of.
5) While typing he should be given auto-complete suggestions so he would not have to type the exact phrase.
6) The amount of records will be about 15,000.
So which is the best way to store and retrieve data as fast as possible?
What file type would you suggest? Should the data be split into many files? Can I use a specific API?
I would really be thankful for any directions here, as I am new in android development, but experienced in desktop applications.
EDIT :
Since I had no answers in many days, I would like to know if my question is not clear enough or if it has already been answered. Please comment.

how to insert images, links, carriage return into Searchable Dictionary for Android

I am developing a glossary using the sample code Searchable Dictionary. Thanks to searching here, I have figured out how to update the database, which is a .txt file, and then get it to load by changing the version number in Dictionary.java.
My question is, how to do the following:
I would like to be able to insert illustrative images into the definitions.
I would also like to insert links to other entries in the dictionary (e.g. 'inventory' should have a link to 'product flow' and other related terms).
I would also like to know how to insert a carriage return.
My original glossary in spreadsheet format has several fields: 'term' 'definition' 'example' 'related terms'. I want to be able to put in links and images inside these fields and have a couple of carriage returns in between each field to differentiate them.
The dictionary code seems to take in everything as a string, so even if I try to put 'image.jpg', or '\n' for a new line, it simply prints that as part of the string. Is there a way around this?
Searching stackoverflow gave a few links to using SQLite. I am honestly a newbie at all this; the last time I programmed anything significant was ten years ago. Rewriting the code to directly access a SQLite database would be nontrivial for me. So I would like to know if that is really the route I should be taking. If it is, then could you point me to the most simple tutorials for constructing a dictionary that way? I downloaded SQLite data browser, but haven't figured out how to use to construct a new database. I know it should not be so hard; I just don't know what I am doing. :(
If there is an easy way to just do it inline, still using the Searchable Dictionary sample code as a base, that would really make my day. Otherwise, any specific suggestions/directions would be really appreciated.
Thank you!!
Update:
For clarification, below is an example of one entry in my glossary, as desired. There are carriage returns between sections, and links and images are inline with text:
Heijunka, or Load Leveling - An approach to smooth production flow when a mix of products is to be produced, by identifying for a selected time period, the smallest batch size at which to produce each specific product in the mix, before switching over to make another product in the mix.
Example:
Keeping a steady work flow, even if much slower than the original max, reduces waste (<-this is a link to the entry 'waste' in the glossary):
[image of line of balance graph with load leveling, and without]
Related Terms: work structure, demand leveling (<-These are links to respective entries)
Not sure if you saw this already, but Android has some developer lessons for saving Key-Value sets for simple data, and saving to SQLlite for more complex structures.
It sounds like your app needs a database called "Invetory" with the following fields: "ProductImage", "ProductTitle", "ProductLink". And you want to store the image as a BLOB. There's a good SO post on how to take an image from a URL and convert it to a byte array for storage: how to store Image as blob in Sqlite & how to retrieve it?
For the carriage return, i'm assuming you're using "\n"? If that's not working have you tried unescaping your string for TextView:
String s = unescape(stringFromDatabase)
Or for SQLlite:
DatabaseUtils.sqlEscapeString()
Key-value data: http://developer.android.com/training/basics/data-storage/shared-preferences.html
SQLlite data: http://developer.android.com/training/basics/data-storage/databases.html
Additional SQLite resources:
http://www.youtube.com/watch?v=G8ZRXdztESU
http://www.vogella.com/articles/AndroidSQLite/article.html

How should I store data to make it easy and efficient to search in android

What I have is an app that displays some documents. In the string resources I have the documents divided into smaller pieces in anticipation of making them searchable. Think of them like newspapers with a number of articles where each article is a separate string resource. There will not be any storing of user input (unless I decide to store recent searches). In the search part of the android developer docs it mentions this but says it is not going to go into details of how to store and search data just how to use the search dialog and widget.
What kind of storage of my data should I be using. Is simple string resources good? should I look into a real databasing? which of these make it the most efficient and quickest to search? I'm new to android so any help would be appreciated.
answer:using android's built in sqlite database system and FTS3 tables.
I would definitely use a database for this.
Read all the documents and link each word to each document in a database.
A word search would then produce a list of documents containing this word quickly.
Make sure you reindex each time you add and remove a document.
By the way, you should see to improving your accept rate.
Also, this is problably not a Android question.

Categories

Resources