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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T13:53:45+00:00 2026-05-16T13:53:45+00:00

Following the Android sample for populating a ListView , I query an array from

  • 0

Following the Android sample for populating a ListView, I query an array from my strings.xml using Activity.getResource().getStringArray():

String [] mDefinitions = getResources().getStringArray(R.array.definition_array);

The documentation for this method is pretty clear and I didn’t expect to encounter any problems with it:

Return the string array associated with a particular resource ID.

This approach worked as expected for small data sets. However, when I populated strings.xml with the full data set (close to 2000 entries), I find that the app crashed when it tried to load the resource. I noticed this error in the console log:

ReferenceTable overflow (max=512)

Playing around with the number of items in my string-array I confirmed that the error was reproducible when the number of items exceeded ~700 entries.

Googling the problem has turned up some examples of other developers having the same problem, but I can’t find anything in the Android documentation to explain it.

Someone has gone to the trouble of creating an issue for the problem on the Android Google Code page but neither it, or any of the posts I came across, received a satisfactory answer.

Am I approaching the problem the wrong way? Should I be populating the data myself (loading a file and parsing JSON or similar) and avoid the issue entirely? It feels like I am missing something obvious here.

  • 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-16T13:53:46+00:00Added an answer on May 16, 2026 at 1:53 pm

    I need to be able to parse large XML files for my particular application (I already had data encoded that way and I wanted to keep it consistant).

    So my first attempt was to use getStringArray, which suffers from the problem described in the question:

    String [] mDefinitions = getResources().getStringArray(R.array.definition_array);
    

    My second attempt suffers from the same limitation that I encounted with getStringArray. As soon as I tried processing a larger XML file (> 500K), I got a DalvikVM crash on getXml:

     XmlResourceParser parser = getResources().getXml(R.xml.index);
    
     try {
         int eventType = parser.getEventType();
    
         while (eventType != XmlPullParser.END_DOCUMENT) {
             String name = null;
    
             switch (eventType){
                 case XmlPullParser.START_TAG:
                     // handle open tags
                     break;
                 case XmlPullParser.END_TAG:
                     // handle close tags
                     break;
             }
    
             eventType = parser.next();
         }
     }
     catch (XmlPullParserException e) {
         throw new RuntimeException("Cannot parse XML");
     }
     catch (IOException e) {
         throw new RuntimeException("Cannot parse XML");
     }
     finally {
         parser.close();
     }
    

    My final solution, which uses the SAX parser on a InputStream generated from the raw resource works. I can parse large XML files without the DalvikVM crashing:

     InputStream is = getResources().openRawResource(R.raw.index);
     XmlHandler myXMLHandler = new XmlHandler();
    
     SAXParserFactory spf = SAXParserFactory.newInstance();
     SAXParser sp = spf.newSAXParser();
     XMLReader xr = sp.getXMLReader();
    
     xr.setContentHandler(myXMLHandler);
     xr.parse(new InputSource (is));
    
     } catch (Exception e) {
         System.out.println("XML Pasing Excpetion = " + e);
     }
    

    Where XmlHandler is:

     public class XmlHandler extends DefaultHandler {
    
         @Override
         public void startElement(String uri, String localName, String qName,
         Attributes attributes) throws SAXException {
         // handle elements open
         }
    
         @Override
         public void endElement(String uri, String localName, String qName)
         throws SAXException {  
         // handle element close
         }
    
         @Override
         public void characters(char[] ch, int start, int length)
         throws SAXException {
         // handle tag characters <blah>stuff</blah>
         }
    
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 530k
  • Answers 530k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think that the behavior you are observing is correct.… May 16, 2026 at 11:29 pm
  • Editorial Team
    Editorial Team added an answer EDIT: Calling toString() will always create a new string... although… May 16, 2026 at 11:29 pm
  • Editorial Team
    Editorial Team added an answer One way to do this in the template would be… May 16, 2026 at 11:29 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am trying the following sample app for twitter oauth. http://www.androidsdkforum.com/android-sdk-development/3-oauth-twitter.html private void askOAuth()
I have a very simple Android activity layout like this: <?xml version=1.0 encoding=utf-8?> <LinearLayout
I've started learning Android development and am following a todolist example from a book:
I currently have a Service in Android that is a sample VOIP client so
I've found a sample to download a large data file at the following link,
I am using Android emulator with AVD of Android 2.1 and I have the
I have problem with fb sdk for Android (downloaded from http://github.com/facebook/facebook-android-sdk ). Tried to
I am trying to post messages to facebook wall using Android's default Facebook client.
There are the following layout options to create interfaces for android. AbsoluteLayout FrameLayout LinearLayout
I just encountered the following situation. I have an Android app with a scenario

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.