Answer the question
In order to leave comments, you need to log in
Where to store text fragments of several paragraphs?
I want to try to make an application for a smartphone in Android Studio , and right at the start I doubted where it is better to store pieces of text with a volume of about 2-3 paragraphs?
Then these pieces should be used to display to the user. I'm leaning towards the strings.xml string resources, but still I would like to know what suits me better.
For each fragment, I also want to associate type tags so that the fragment is displayed when clicked, for example, on the tag "cat" or "pet", will lines. xml go for such purposes? Or is it better to shove everything into SQLite?
Answer the question
In order to leave comments, you need to log in
First you need to decide whether you need localization of your texts.
1. strings.xml are good in this regard, because it is very easy to add a translation by creating a string resource corresponding to the locale you need, and then the desired option will be automatically selected by the system.
2. If the translation is not really needed, you can store the data in the database, but then it will need to be deployed along with the application - this must be provided for. Here it is better to have a separate database, so as not to bother with the upgrade of the scheme in the future.
3. Another option is to store in JSON files, which are also put in the application's assets.
4. The most versatile, but network-dependent option is to store resources on the server and load them, depending on your needs.
XML is not suitable for search. Technically, of course, you can search, but from the point of view of resources - hellish hell) It is better to use something similar to a database.
raw or assets and write methods for reading from the file in some helper class for convenience.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question