0

In my android app I created a table where the user can add rows by clicking on the button "add", I managed to do that but I would like to know if there is a way to save the tableLayout the user generated dynamically in order for him to close the app and then if he opens it again he will get the same table with the rows he created so he can keep adding rows to the table.

This is the code i used fot the button add onClick property

public void onClickAdd(View view) {

  TableLayout table_layout = (TableLayout) findViewById(R.id.table_layout);

  TableRow row = new TableRow(this);
  //add properties to row 
  tabla.addView(row);
}

My first thought was using sharedPreferences but I am new in apps developing and i don`t know if there is a simpler method.

Thank you in advanced and sorry for my english it's not my first language.

narib
  • 19
  • 4

1 Answers1

0

SharedPreferences would be the best route unless your users will need to save hundreds of rows, or more. Then you would probably want to use a database:

Pros and Cons of SQLite and Shared Preferences

Community
  • 1
  • 1
Jim
  • 10,172
  • 1
  • 27
  • 36
  • Thank you, finally I used SharedPreferences because it seem to work better and it was easier to implement. – narib Nov 20 '14 at 09:00