Simple data


Last Updated:

  1. rick99gtp

    rick99gtp Member This Topic's Starter

    Joined:
    Aug 6, 2010
    Messages:
    12
    Likes Received:
    0
    When searching for how to store small pieces of information for my app I run into this a lot, "Unless your application deals only with simple data, you need a database system to store your structured data".

    So, how do I handle simple data? With FileInputStream? Where is this hard to find data/data folder?

    Anyone have information to share?

    Thanks

    ~Rick
     

    Advertisement
  2. blundell

    blundell Well-Known Member

    Joined:
    Apr 23, 2010
    Messages:
    125
    Likes Received:
    17
  3. rick99gtp

    rick99gtp Member This Topic's Starter

    Joined:
    Aug 6, 2010
    Messages:
    12
    Likes Received:
    0
    Either I don't understand how I would utilize the Preferences you recommended or I didn't explain myself very well. :)

    I'd like to store the user's best score in a data file and be able to read it back in and display it on screen when needed. Can I do this with Preferences?
     
  4. blundell

    blundell Well-Known Member

    Joined:
    Apr 23, 2010
    Messages:
    125
    Likes Received:
    17
    Yes you can :-D!
    SAVE:
    Code (Text):
    1.  
    2. SharedPreferences.Editor editor = getPreferences(0).edit();
    3. editor.putInt("highScore", 39999);
    4. editor.commit();
    5.  
    RETREIVE:
    Code (Text):
    1.  
    2. SharedPreferences prefs = getPreferences(0);
    3.  int highscore = prefs.getInt("highScore", -1);
    4.  
     
    rick99gtp likes this.
  5. rick99gtp

    rick99gtp Member This Topic's Starter

    Joined:
    Aug 6, 2010
    Messages:
    12
    Likes Received:
    0
    Ah, ha! You're a genius! ;)

    I wondered if there was a way to save game state in this fashion. Thanks so much!
     

Share This Page

Loading...