Save tableLayout generated dynamically by adding rows on click button

468 Views Asked by At

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.

1

There are 1 best solutions below

1
On BEST ANSWER

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