Following
this Xamarin suggestion I think I'm able to persist the data if I serialize the object to a Json string. However something is wrong. My "savedInstanceState.GetString("jsonData")" always comes back null because OnSaveInstanceState never gets called!!
Here is my code:
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.CaseControl);
RelativeLayout layout = FindViewById(Resource.Id.layoutCasos);
grid = new SfDataGrid(this);
grid.AllowResizingColumn = true;
grid.AllowSorting = true;
layout.AddView(grid);
if (savedInstanceState != null)
{
string savedJsonData = savedInstanceState.GetString("jsonData");
grid.ItemsSource = JsonConvert.DeserializeObject
>(savedJsonData);
}
else
{
string dpPath = Path.Combine("/data/data/TPProject.TPProject/files/", "PranfHurto.db3");
var db = new SQLiteConnection(dpPath);
var data = db.Table();
grid.ItemsSource = data;
jsonData = JsonConvert.SerializeObject(data);
}
grid.SelectionMode = SelectionMode.Single;
grid.GridLongPressed += RowLongPress;
}
protected override void OnSaveInstanceState(Bundle outState)
{
outState.PutString("jsonData", jsonData);
base.OnSaveInstanceState(outState);
}
So, what I'm doing wrong?? Help! Thank you!