Search code examples
androidandroid-xml

How to get a value of a string resource in constants file?


i am working on an application where i have to get a value of string resource to a constant. how can i do that? any ideas please.

The String is placed in

Application/res/values/strings.xml

and the name of the resource is let say app_version. now i want to get this app version to a constant string in another file. Any help is appreciated.


Solution

  • In Java: R.string.string_name 
    In XML:@string/string_name
    

    R.string.app_version or @string/app_version taken from strings.xml is your constant and will always represent the value you entered into that XML file.