1. Download our Official Android App: Forums for Android!

Apps Best method for declaring / populating arrays

Discussion in 'Android Development' started by plebtastic, Feb 7, 2013.

  1. plebtastic

    plebtastic Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Feb 7, 2013

    Feb 7, 2013
    2
    0
    5
    Hi,

    In terms of efficiency, is it better to use arrays programmatically or through calls to xml files.

    I'd prefer to use xmls for organisational reasons, but is there much of a performance hit.
     

    Advertisement

  2. jonbonazza

    jonbonazza Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,930
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    1,930
    457
    163
    Male
    Populating via xml will have an overhead and be a little worse in terms of performance than programmatic population, but not by much. Depending on the problem and the size of the data set, I would say that xml would be the better choice.


    Actually, are you referring to your own xml files or the built-in android xml arrays?

    If you use android's built-in arrays.xml stuff, there won't be any overhead at runtime. android interperates the xml at compile time and generates the array for you.
     
  3. plebtastic

    plebtastic Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Feb 7, 2013

    Feb 7, 2013
    2
    0
    5
    Thanks.

    I usually create an 'arrays.xml' file and put all arrays in there.
    Is this considered a built-in xml?

    Eclipse creates strings.xml and values.xml by default, so I'm not sure what the built-in ones you refer to are!
     
  4. jonbonazza

    jonbonazza Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,930
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    1,930
    457
    163
    Male
    yes, I consider arrays.xml a built in xml as it is interperated at comile time by the ADT.
     

Share This Page

Loading...