Guest User

Untitled

a guest
Jan 23rd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. this.connect = function()
  2. {
  3. try
  4. {
  5. var oldHandle = Titanium.App.Properties.getString('handle');
  6. //Handle is Not empty, lets removed Cached DB
  7.  
  8. if(oldHandle!="")
  9. {
  10. Ti.API.info("Connected baby with Old Handle = "+oldHandle+ " and Db file ="+ this.dbName);
  11. //Get the Handle
  12. var dbOld = Titanium.Database.install(this.dbName,oldHandle);
  13. // Destroy It
  14. dbOld.remove();
  15. //Reset the Handle Property to Empty
  16. Titanium.App.Properties.setString('handle',"");
  17. Ti.API.info("Removed Old Handle = "+oldHandle );
  18.  
  19. }
  20. //Install Fresh One
  21. connection = Titanium.Database.install(this.dbName,this.dbHandle);
  22. Titanium.App.Properties.setString('handle',this.dbHandle);
  23. Ti.API.info("Installed New DB with Handle ="+this.dbHandle);
  24. return true;
  25. }
  26. catch(ex)
  27. {
  28. Ti.API.info(ex.description);
  29. return false;
  30. }
  31.  
  32. }
Add Comment
Please, Sign In to add comment