1. Are you ready for the Galaxy S20? Here is everything we know so far!

Simple data

Discussion in 'Android Development' started by rick99gtp, Aug 9, 2010.

  1. rick99gtp

    rick99gtp Newbie
    Thread Starter

    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
     



    1. Download the Forums for Android™ app!


      Download

       
  2. blundell

    blundell Well-Known Member

  3. rick99gtp

    rick99gtp Newbie
    Thread Starter

    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

    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 Newbie
    Thread Starter

    Ah, ha! You're a genius! ;)

    I wondered if there was a way to save game state in this fashion. Thanks so much!
     
Loading...
Similar Threads - Simple data
  1. dfghyyt37
    Replies:
    1
    Views:
    350
  2. androinewbi
    Replies:
    6
    Views:
    1,120
  3. App Update
    Replies:
    0
    Views:
    421
  4. ChristopheA
    Replies:
    4
    Views:
    1,024
  5. RASelkirk
    Replies:
    7
    Views:
    507
  6. nullshxt
    Replies:
    3
    Views:
    628
  7. Brad Wood
    Replies:
    6
    Views:
    673
  8. Ajhalls
    Replies:
    0
    Views:
    1,502
  9. Samsung
    Replies:
    0
    Views:
    869
  10. App Update
    Replies:
    0
    Views:
    289

Share This Page

Loading...