NimbleKit - fast iOS app development

Home Screening app messes up details page and more

Problem discussions

Home Screening app messes up details page and more

Postby bradmoss » Fri Apr 29, 2011 12:44 am

My app creates the tableView and binds a database to it. When I press on a row it opens a details page. However, when you homescreen the app... and then come back if you click on any row the details page that shows doesn't have any data in it anymore. I have to reload the app with a fresh database to get it fixed.

So I figured the way around this would be to dynamically load a TableView with an Array.... which worked fine and dandy... it even fixed the issue of the details page messing up however, I can't for the life of me figure out how to get the tableView to refresh the way I want it to.

Options I've tried.... using onPageShown(caller) to reload the array from the database and insert records. All that does is add the new records plus the old records to the bottom of the current tableView.

I've also tried reinitializing the tableView variable which essentially just slaps one tableView on top of the old one and I've tried various ways of getting the old one to hide so the new one can sit on top of it, but I'm about to give up. Please please help!
User avatar
bradmoss
 
Posts: 35
Joined: Thu Apr 14, 2011 6:15 am
Location: Webb City, MO

Re: Home Screening app messes up details page and more

Postby floz » Fri Apr 29, 2011 10:56 am

In think this is exactly the bug I reported here, and as far as I know Sunny's already working on it. At least he's aware of it.

Basically, what happens is that the minute you bind a table to a database, and that table contains more than just the 6 standard fields required for binding, then those fields get deleted when the app is paused (or so).

Now as a temporary fix --- if your app is never meant to modify anything in the database, the you can use the following workaround. Just add the following code to your main.html file:

Code: Select all
<script type="text/javascript">
   var database = new NKSQLite();
   database.openDatabase("YOURDB.sqlite", "yes");
   database.closeDatabase();
   function OnApplicationResume(){
      var database = new NKSQLite();
      database.openDatabase("YOURDB.sqlite", "yes");
      database.closeDatabase();
   }
</script>


Some more background on this (as I understand it, anyway): This is related to the fact that the database exists in two locations: First, it sits in a read-only location, and hence can't be modified there. That's why NK internally makes a copy of the DB to a location where it can be read and written to. And in that location it then gets messed up. Now, if you use openDatabase with "yes" at the end, you force NK to copy the file over again. Hence, on application resume, the "broken" DB is immediately overwritten, and all is good again.

However, this way you can't make any edits to your DB on the device, as those would be constantly thrown overboard with the "hack". That's way I hope that a fix is released sooner than later. (But again, sunny's working on it already).
User avatar
floz
NimbleKit Guru
 
Posts: 261
Joined: Sat Feb 05, 2011 2:07 pm
Location: Newcastle, Australia


Return to Troubleshooting

Who is online

Users browsing this forum: No registered users and 1 guest