There is a database. I need to use the characters: b, i, u, h2 and space. If you print to textview from string , then you need to write text with tags between DATA . And what to do in the "DB" to support html tags? Shielded?

  • The database, in general, does not care what is stored in it. - D-side
  • Those. If I write in the DB cell: "<b> hello </ b>" and output it in a textview, then the word "hello" will be highlighted in bold, and not "<b> hello </ b>"? - Sergey
  • It does not depend on the DB. The database simply stores the data. The output format is already up to you. - D-side
  • No, well, for example, in string html it is not supported, unless you specify support in output in Java: html.fromhtml. and the tagged text itself is not between: cdata. so I ask about the database. So cdata is not suitable, and therefore tags are not supported. - Sergey
  • Again. The database stores just a sequence of characters. The meaning and form of it gives the code that deals with its output to the screen: with pre-processing, analysis or whatever it was. - D-side

1 answer 1

Only special characters should be escaped in the database, at the time of writing SQL queries, such as apostrophes, single quotes, back slashes. This is necessary in order for the database request to be executed correctly, and not to be executed with an error or, for example, not to destroy your data in the database. HTML may contain single quotes, apostrophes and anything else, so you will have to escape sooner or later.

  • And it is better to use adapters for the database with the support of parameterized queries, in which you do not need to manually shield anything. - D-side
  • It is necessary for me that on pushing the button from a DB the certain cell in textview was taken out. In the database cell will be the text with html tags. So, what should be shielded? I write text with tags in the database as I would do in string, and do I need to escape special characters when querying DB? - Sergey