C
C
calculator2122021-08-09 17:01:05
Android
calculator212, 2021-08-09 17:01:05

Where in code are strings from strings.xml stored in Android studio?

In general, such a question arose and I do not know how to google it correctly. In Android studio, you can refer to some string from strings.xml, as if this variable is in some class, although in reality they are only registered in the xml file at this point in time. Do I understand correctly that when building a project, these lines are auto-generated somewhere and then the programmer can already access these lines?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Zagaevsky, 2021-08-10
@calculator212

The lines are in xml (maybe packed in binary form) in the application's resources. An R-file is also generated (the IDE generates it, and it is also generated during the build), it contains the line IDs, not the lines themselves. In runtime, lines from resources are read by IDs from the R-file, there is a special Resources class, it uses AssetManager. When you do
context.getString(R.string.mystring) or context.getResources().getString(R.string.mystring) this is what happens.
If you want to know more - open the code and read it.

D
Developer, 2021-08-09
@samodum

Well, this is the basics of android. Every book talks about this on the first page.
No, you misunderstood. The programmer has access to resources immediately in the code.
Google basic documentation or books for beginners

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question