How to Read 2D Arrays on the XML in an Android App

'); dmjs.revenueTags.push('ca-ehow_160x600;cpu_computer_programming,text,suggested7'); googleAds.addAdUnit({ priority : 3, adUnitId : 'GoogleAdsense160x600', google_ad_channel : 'cpu_computer_programming,text,suggested7', google_ad_client : 'ca-ehow_160x600', google_max_num_ads : '5', google_hints : '', google_image_size : '160x600', google_ad_type: 'text_image_flash', templates : { text : '' } }); }

Jim Campbell

Jim Campbell has been a computer engineer for over five years. He excels in hardware repair, computer programming and troubleshooting, and software design. He is currently attending Florida Atlantic University, pursuing a master's degree in computer and electrical engineering and fine-tuning his technical writing abilities.

updated December 24, 2011

Android developers use Java to create the layout XML and the functionality of an Android app. You use Java to read a 2D array in an XML file, which contains the settings and stored values you use in an Android app. Java includes functions and features that let you read the Android's XML variables in order to import them into users' screens.

Difficulty:
Moderate
    • 1

      Open the Eclipse Android editor and the project you want to edit. Double-click the Java source code file you want to use to read the XML file.

    • 2

      Create a content list array variable. This is the variable you use to contain the array values. The following code creates the variable:

      List<String> xml = new ArrayList<String>();

    • 3

      Open the XML file that you want to read. The following code opens a file named "myfile.xml":

      BufferedReader array = new BufferedReader(new FileReader ("myfile.xml"));

    • 4

      Loop through each array element from the XML file and store the results into the new XML array created earlier. The following code reads the array into your Java Android app variable:

      while (( string newvalue = array.readLine()) != null){
      xml.add(newvalue);
      }

    • 5

      Click the "Save" button, then the "Run" button in the editor to execute and test the new Android code.

Read Next:

Source: http://c.moreover.com/click/here.pl?r5662488954

happy holidays norad how to carve a turkey how to cook a turkey dog the bounty hunter yorkshire pudding obscura