Store large, structured text in an Android app

What is the most suitable way to store some structured texts? The texts will be a collection of "books". Each book contains a collection of articles, and each article has a title and body.

The ways I could think of are as follows:

  • create a database using sqlite

  • write xml file in assets

  • put them in res / value / string

  • use java string

Which method is best for my situation? Is there a better way than the ones listed above?

Thanks in advance.

===========================

edit: Yes, the data can be considered static.

+4
source share
2 answers

XML or any other format you prefer in res/assets is the preferred way if your data is static (it will not change).

If you want to work with dynamic data collected from webapp, for example, you should use the built-in SQLite database.

+3
source

If you are looking for persistent storage, I would suggest a small SQLite database. You can also save it in XML documents and then use the ContentProvider to abstract access to books, but then you will have to write the I / O and XML analysis operations yourself.

+1
source

Source: https://habr.com/ru/post/1432670/


All Articles