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

  • SEARCH
  • Home
  • 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 7080039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:44:45+00:00 2026-05-28T06:44:45+00:00

Ok, so this question is a bit weird, and kinda rubs me the wrong

  • 0

Ok, so this question is a bit weird, and kinda rubs me the wrong to even ask, but since I probably don’t have a choice I want to see what you guys think. I’m still a novice at Java and Android.

The case is as follows: We are trying to automate the building of our strings.xml for localisation. A parser has been made to convert a csv-file to xml. For regular strings it’s not a real problem, that works fine. But the parser that was built, doesn’t take string arrays into account and there is little chance that someone will modify it.

Is there an “easy” way to work with the strings and create an string array programmatically based on parts the name attributes?

If not, then I would have to hard code the arrays and that leaves the creator (client) of the language files unable to add items to something that should be a dynamic list.

I know modifying the strings.xml manually might be an option, but because our management wants to automate stuff like that, it’s not much of a choice I have.

Probably I will hard code the stuff and say they can’t dynamically fill the lists, but still (also for my personal education) I wanna know what you guys think.

Thanks for your opinions or solutions. 🙂

Cheers!

  • 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-05-28T06:44:45+00:00Added an answer on May 28, 2026 at 6:44 am

    So you will get strings.xml as below

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <string name="string1">1st string</string>
        <string name="string2">2nd string</string>
                     ........
        <string name="stringN">Nth string</string>
    </resources>
    

    I suggest a simple modification to strings.xml, which is add a string with name count at top of all strings with value equal to total number of strings and add another string with name prefix below the count, then it looks like as below.

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <string name="count">4</string>
        <string name="prefix">string</string>
        <string name="string1">1st string</string>
        <string name="string2">2nd string</string>
        <string name="string3">3rd string</string>
        <string name="string4">4th string</string>
    </resources>
    

    So now, in your java file you can access them like below

    int count = Integer.parseInt(getString(R.string.count));
            String prefix = getString(R.string.prefix);
            String[] strings = new String[count];
            for (int i = 0; i < count; i++) {
                strings[i] = getString(getResources().getIdentifier(prefix+(i+1), "string", getPackageName()));
            }
    

    I hope it may help you.

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

Sidebar

Related Questions

This question may seem a little bit stackoverflow-implementation specific, but I have seen a
Strange Question i guess but i have this bit of code in my page...
this question sounds a bit confusing, but here is what i have: <div id=type2>
This is a bit of a weird question but, with the functionalities of C++,
This may be a bit of a weird question, but is there any reliable
I noticed This question , but my question is a bit more specific. Is
I know this question has been asked a bit before. But looking around I
I have a bit of a weird question here. I am using iperf to
This is a little bit of weird problem here. Say I have a C++
This may sound like a weird question but I will give it a shot

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.