Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8529481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:02:39+00:00 2026-06-11T09:02:39+00:00

In my app I have numerous strings used to identify a region and location.:

  • 0

In my app I have numerous strings used to identify a region and location.:

<string name="r1s1">Seattle</string>
<string name="r1s2">Des Moines</string>
<string name="r1s3">Bremerton</string>
<string name="r2s1">Tacoma</string>
<string name="r2s2">Burton</string> etc, etc.

I can readily access these strings by string name by using a long switch statement:

switch(regionCode
{   case 1: sN=getString(R.string.r1s1);break;
    case 2: sN=getString(R.string.r2s1);break;  etc etc

I want to calculate this string name and use it to access the string more directly:

stationNameKey="r"+regionCode+"s"+stationCode;// e. g. r1s1
stationName=getString(R.string.stationNameKey);

This second statement is not correct and will not compile here is the message:

! compiler error:: stationNameKey cannot be resolved or is not a field.

I assume a cast from String to Resource Name Identifier would work but cannot find it.

Q: How do I cast a string to make my second statement work correctly. Thank You.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:02:40+00:00Added an answer on June 11, 2026 at 9:02 am

    You should use Resources.getIdentifier()
    see this and this

    int resId = getResources().getIdentifier(stationNameKey,"string",null);
    

    should work to get the id you need

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have numerous activites in my Android app., and most should contain the same,
In my app I have to download JSON data from numerous web services. The
I have an android app which populates a SQLite database with numerous latitudes and
I have used PHP to access MySQL databases numerous times for projects on our
My app have a background image that fills the screen. I'd like to display
my app have action bar on top of windows. Where are some buttons. Buttons
In my app have a sign in activity. If login is successful, I start
I'm using EasyTracker google analytics library and my app have multiple activities. I want
This is a continuation of the question here: JBoss - does app have to
we have app hosted on google app engine for java. In this app we

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.