I m working on app which uses sqlite database . I got sucess to store Strings in various languages and also fetching from database .
But My problem is that i want to store it in bold or italic style.
Is it possible ?? If yes then how can i achieve that kind of thing ?
Any help will be appreciated.
Format the strings using html.
When you want to display them use Html.fromhtml( your string)
E.g.
String myboldstring = <b>boldy</b>
textView.setText(Html.fromhtml(myboldstring));
Is it what you want?
As an alternative to LazyN's solution I suggest you look at using a standard markdown language for this kind of context (much as stack overflow does). There are several advantages:
Widely used around the web so your users are likely to understand how to use it.
Much more secure in the sense that one cannot inject malicious HTML/javascript; this is very difficult to prevent once you allow any HTML as LazyN suggests
Trivial to store/export/import etc as it is all legal text string
Related
I am working on an Android app which will store long texts, images etc. A 'guide' app in other words. But I am not sure which one would be the best way(or the most logical way) to do this. Storing the texts in strings.xml, using HTML&CSS and showing it using WebView, using databases, or something else?
That depends a bit on where the text is coming from, IMHO.
If the text is baked into the app, and it will only change via an update to the app itself, I'd use HTML/CSS and store it in assets/. They can then be loaded using loadUrl("file:///android_asset/...") in a WebView. If you wanted full-text search, you could prepare a SQLite database with an FTS table and package that with the app as well, unpacking and using it on the first run of the app.
If you plan on downloading the text, then the decision hinges more on what the server is serving, as you're probably stuck with that format. That, in turn, would influence the storage approach.
String resources (strings.xml) are fairly clunky for long bits of text.
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
I'm developing an android app in which we're going to display some mathematics and physics question with multiple-choice answers.
The text of the questions are ready on a Microsoft Office Word .docx format.
The text of the questions usually contains formulas and equations and we want to save them in a SQLite database and access to it on android app.
The real problem is how to manage the displaying part, since to the best of my knowledge, we should manage such complex text with html tags.
There are actually about at least 2000 of these questions and we're after an optimized solutions for the problem.
and I'm a tough guy ! :) just give me some keywords and I'll go get it done.
So, please share your experiences and suggestions.
An easy solution, mentioned in the comments, would be to use MathJAX.
An alternative, if you only have about 2000 formulas, would be to set up TeX on your local machine, generate the formulas, and convert into individual png images.
You could also use HTML+Unicode directly if the formulas are simple.
I would like some advice. I'm going to be using an sqlite database that will be pulling down information from my server and then saving it in the DB then displaying it. Could someone advise me of the best way to populate the DB, should I...
Use a http request and return a string de-liminated with say a | and use a loop to write to the data base.
Use a JSON to retrieve the information and then store it in the database.
The information is going to be just text and some fields will contains links to images I want to then download (get to that later). Just wanted some advice on best practices. I have done some searches on SO and other sites but can't find much advice. Also as a side note any examples you know of that are good for noobs :)
Based on what you write here I would pick JSON.
To core points:
JSON is a standard format.
Android ships with a JSON lib (org.json) making it easy to handle it (encode / decode data).
JSON is known by a large community so you can ask questions and get them answered rather easily. With a custom format you cannot tag the question as 'json' here at SO... ;-)
Using standard formats and libraries helps you to avoid designing and implementing this stuff yourself, which makes your software more robust.
Sometime later you might need to add more complex data to your project. By that time it will be rather straightforward to use JSON's array and objects. With your private scheme you will have to add this capability to it and extend your parsing code. That can easily introduce subtle bugs. Or you might decide at that point that it is too hard with your custom format and decide to move over to a standard like JSON, XML, etc. At that time it costs you much more to shift over than if you start with a standard format. Consider time invested to write and test the current code and then the extra time to change to the standard format for the current system.
I am working on an Android app that I would like to code in such a way so that the Spanish characters coming from the database are read as equivalent to the English ones. For instance, cafe and café would be identical.
Is there a way to do this?
Do you mean that you want queries to find both "cafe" and "café" when you search for "cafe"? You should be able to use a regular expressions to do this.
If this needs to be done on the fly, you could write a function that parses the request for 'e' and generate the correct regular expression before creating the DB query.