0

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:

  1. I would like to be able to insert illustrative images into the definitions.
  2. 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).
  3. 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)

1 Answers1

0

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:

Community
  • 1
  • 1
phteven
  • 1,383
  • 2
  • 16
  • 29
  • So you do think that I should be using a database instead of the sample dictionary code? I'm reading the links, and they seem quite advanced to the level of expertise I am at now. Does anyone know of another sample or shell I could use instead? – user2360034 May 09 '13 at 06:39