how to store application configuration asks a Newbia


Last Updated:

  1. horatio

    horatio Member This Topic's Starter

    Joined:
    Feb 28, 2010
    Messages:
    17
    Likes Received:
    0
    Hi All,

    New to Android! Can anyone tell me the best way to store application configuration? I want to store items such as URLs and so on. I'm thinking of using Apache Commons configuration but that would mean bundling those jars with my application. Is there a native Android way to do this?

    Thanks,
    John.
     

    Advertisement
  2. KlaymenDK

    KlaymenDK Well-Known Member

    Joined:
    May 29, 2009
    Messages:
    1,217
    Likes Received:
    130
    Use the official docs. :)

    Specifically, you want to look at Preferences (if I understand your question correctly).
     
    horatio likes this.
  3. horatio

    horatio Member This Topic's Starter

    Joined:
    Feb 28, 2010
    Messages:
    17
    Likes Received:
    0
    Thanks KlaymenDK. That's not quite what I'm looking for however. I want to store application configuration that is never presented to the user. My application will need to make periodic calls to a RESTful web service and I need to store the URL some place that my app can read on initialisation. This shouldn't be presented to the user to change. Is there something like the Windows registry or INI files available for example?

    Cheers,
    John.
     
  4. KlaymenDK

    KlaymenDK Well-Known Member

    Joined:
    May 29, 2009
    Messages:
    1,217
    Likes Received:
    130
    Okay, I misunderstood you, then.

    There is no global registry; the prefs system is explicitly intended to store app-specific tidbits; you can use it for storing stuff (say, internal state information) without ever interfacing the user. Or, you could look into the "instance states" discussed here (although data stored this way won't survive a reboot).

    I had better info but I can't find the links right now! :eek:
     
  5. horatio

    horatio Member This Topic's Starter

    Joined:
    Feb 28, 2010
    Messages:
    17
    Likes Received:
    0

Share This Page

Loading...