How to extract string resource in Android studio (APG-17)
Rajesh Hadiya
Helps you to master Android & Spring Boot ?? Aaye hain to thoda content dekh ke jaiye ?? Join our next Android meetup (pinned post ??)
When working on an Android project, you use lots of strings in Activity/Fragments/Composable. As per official guidelines, and to take benefit of internationalization, you should not use hardcoded strings in your app. Rather, you should use string resources from res/values/strings.
But Going to the string resource file, making an entry there, and then using that resource in the code is a cumbersome task. If your code contains a lot of strings, this is a huge nuisance.
However, this can be avoided by taking a simple yet effective approach.
Wherever you have string literal in code,
1. Press Alt+Enter to open context menu and select Extract string resource
2. Type the name of the resource and press Enter.
3. Android Studio will take the string literal and turn it into a string resource, which it will then replace in your code.
We also have an android developer community on WhatsApp where we enjoy learning and sharing everything android, including live sessions, interview preparation, job referral, tutorials, and Q&A. Join us if you're interested.
https://bit.ly/adc-whatsapp-02?(Join this if the first group is full)