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

Apps should I use db or not

Discussion in 'Android Development' started by proskier, Jul 27, 2010.

  1. proskier

    proskier Member
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    30
    Joined:
    May 12, 2010

    So my app is very simple that I am building.

    My main activity loads and xml file that is a bunch of tablerows and in my java I manipulate each of the row's background color(xml attribute) via this method


    Code (Text):
    1.     public void colorRow(int id, int starCount){
    2.         if (starCount == 0){
    3.             TableRow row = (TableRow) findViewById(id);
    4.             row.setBackgroundColor(Color.WHITE);
    5.         }
    6.         else if (starCount == 1){
    7.             TableRow row = (TableRow) findViewById(id);
    8.             row.setBackgroundColor(Color.YELLOW);
    9.         }
    10.         else if (starCount == 2){
    11.             TableRow row = (TableRow) findViewById(id);
    12.             row.setBackgroundColor(Color.CYAN);
    13.         }
    14.         else {
    15.             TableRow row = (TableRow) findViewById(id);
    16.             row.setBackgroundColor(Color.RED);
    17.         }
    18.     }
    so prettymuch I want my rows to save when a user exits the app, so when they reopen it the color of the rows will be saved and show properly.

    I was wondering if this would be wise to do with a db, preferences, savedInstanceState, or something else I dont know about.

    Can someone please shed some light on how I should go about doing this? Thanks so much everyone.
     

    Advertisement

  2. amar77

    amar77 Lurker
    Rank:
    None
    Points:
    5
    Posts:
    4
    Joined:
    Jul 27, 2010

    Jul 27, 2010
    4
    0
    5
    I think preferences is the best solution for this :)
     
  3. cp1

    cp1 Android Enthusiast
    Rank:
    None
    Points:
    53
    Posts:
    375
    Joined:
    Apr 30, 2010

    Apr 30, 2010
    375
    35
    53
    It probably depends on how many rows you have.
     

Share This Page

Loading...