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 7420791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:18:03+00:00 2026-05-29T08:18:03+00:00

We can read a string array from xml file in android like mentioned here

  • 0

We can read a string array from xml file in android like mentioned here. But this can only read simple string array.

My question is that can we read array containing some other type of objects. xml file is like this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array
        name="difficulty_level_names">
        <item>
            <name>IELTS</name>
            <type>1</type>
        </item>

        <item>
            <name>SAT</name>
            <type>2</type>
        </item>

        ................
        .........

    </string-array>
</resources>

UPDATE: Of course, there can be more parameters in each item..

  • 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-29T08:18:04+00:00Added an answer on May 29, 2026 at 8:18 am

    No, in the way you provided. I have two solutions on my mind, and both not ideal.

    1.

    You can create multiple arrays, for example string-array for names, integer-array for integer etc. Every object would be stored in those arrays at the same index. It’s not simple to maintain but it may be more memory efficient in case of accesing only one property from object.
    I described it in: https://stackoverflow.com/a/6774856/538169

    Or

    2.

    You can create one typed array and have object’s properties in the array. You could access the property through translating the index in such way:

    final int PROPERTIES_COUNT_IN_OBJECT = 2;
    int objectIndex   = 0; // the first element in your's example
    int propertyIndex = 1; // the second property: <type>1</type>
    int indexInArray  = objectIndex * PROPERTIES_COUNT_IN_OBJECT + propertyIndex;
    

    Then get this property from TypedArray.

    The second solution is much worse to maintain. Adding another property would be a nightmare.

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

Sidebar

Related Questions

I can read settings like this, for example: final String mytest = System.getString(this.getContentResolver(), System.AIRPLANE_MODE_ON);
The values in a file are read as string and can be double, string
How you can read a file (text or binary) from a batch file? There
Trying to read into an object the following XML file (can be changed) into
For JavaScript in most browsers*, you can read a character from a String by
On docs we can read: public static string link(string $text, mixed $url='#', array $htmlOptions=array
In .Net you can read a string value into another data type using either
How can i check the read/ write permission of the file storing media? ie
I can read the MySQL documentation and it's pretty clear. But, how does one
You can read about the 64-bit calling convention here . x64 functions are supposed

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.