Upgrade App lost data

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

sirobchGA0cda
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 47
Joined: Wed Dec 21, 2011 10:42 am
Contact:

Upgrade App lost data

Post by sirobchGA0cda » Sat May 03, 2014 5:40 pm

Hello,
I save my application data IOS with a stack launcher.
I attach the code :

Code: Select all

on openstack
put specialFolderPath("Documents") & "/saving.livecode" into tMainStackPath
if there is not a file tMainStackPath then
   put specialFolderPath("engine") & "/saving.livecode" into tOriginalStackPath   
put url ("binfile:" & tOriginalStackPath) into url ("binfile:" & tMainStackPath) 
end if
go stack tMainStackPath
end openstack
This works perfectly on iPad and in the simulator.
  when I do an update of the application, it remembers the old file into the memory.
I need to deleted the app on the iPad to take the new version, but the data is not retained.
How to install an update keeping all the data.
thank you in advance for your answers
Boris
My application "GeoMaths" is available on Itunes and Google Play !

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Upgrade App lost data

Post by jmburnod » Sat May 03, 2014 7:17 pm

Salut Boris,
I understand there is a file tMainStackPath :shock:
What happen with that ?

Code: Select all

on openstack
   put specialFolderPath("Documents") & "/saving.livecode" into tMainStackPath
   --if there is not a file tMainStackPath then -- there is a file tMainStackPath
      put specialFolderPath("engine") & "/saving.livecode" into tOriginalStackPath   
      put url ("binfile:" & tOriginalStackPath) into url ("binfile:" & tMainStackPath) 
   --end if
   go stack tMainStackPath
end openstack
But you have to know if that is the first openstack of the new version otherwise it will do this at each openstack 8)
Kind regards
Jean-Marc
Last edited by jmburnod on Sun May 04, 2014 8:43 am, edited 1 time in total.
https://alternatic.ch

sirobchGA0cda
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 47
Joined: Wed Dec 21, 2011 10:42 am
Contact:

Re: Upgrade App lost data

Post by sirobchGA0cda » Sat May 03, 2014 8:25 pm

Salut Jean-Marc,
tMainStackPath, it's for saving/loading the stack (saving.livecode) with the data.
Thanks for your code, but he don't save the data when I shutdown the application.
Best regards
Boris
My application "GeoMaths" is available on Itunes and Google Play !

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Upgrade App lost data

Post by jmburnod » Sat May 03, 2014 8:31 pm

but he don't save the data when I shutdown the application.
No. 8)
He probably save the data but openstack set the stack of the documents folder to the stack of the engine folder
That is the reason why you have to know if that is the first openstack with the new version
You can use a file DocInstaller.txt to store infos about the installation history
Read this file at preopenstack, compare infos and do what is necessary and don't forget to
update this file to avoïd an intallation at each openstack
https://alternatic.ch

sirobchGA0cda
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 47
Joined: Wed Dec 21, 2011 10:42 am
Contact:

Re: Upgrade App lost data

Post by sirobchGA0cda » Sun May 04, 2014 6:50 am

Thank you for the reply,
but I do not understand how to do it the difference between a new installation and update. :cry:
If every update my application, you must uninstall the old and lose all the data, I do not think this is ideal.
I will continue looking for a solution, but for now I do not know how.
Best
Boris
My application "GeoMaths" is available on Itunes and Google Play !

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Upgrade App lost data

Post by jmburnod » Sun May 04, 2014 9:20 am

Salut Boris,
If every update my application, you must uninstall the old and lose all the data, I do not think this is ideal.
Anyway, if you replace your stack tMainStackPath, you lost your data :o
I never used stack to store data of an app.
I use files ".txt" in a folder of the documents folder.
Data are saved in those files and read when that is necessary.
In your case I think you can compare the content of a fld or a custom property of the document folder stack and engine folder stack.
Something like that for a customprop of the stack (no tested)

Code: Select all

on openstack
   put specialFolderPath("Documents") & "/saving.livecode" into tMainStackPath
   put specialFolderPath("engine") & "/saving.livecode" into tOriginalStackPath
   if  the uMyVersion of stack tMainStackPath <> the uMyVersion of stack tOriginalStackPath then  
      put url ("binfile:" & tOriginalStackPath) into url ("binfile:" & tMainStackPath) 
   end if
   wait 200 milliseconds -- not sure that is necessary
   go stack tMainStackPath
end openstack
Best
Jean-Marc
https://alternatic.ch

sirobchGA0cda
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 47
Joined: Wed Dec 21, 2011 10:42 am
Contact:

Re: Upgrade App lost data

Post by sirobchGA0cda » Sun May 04, 2014 10:28 am

Salut Jean-Marc,
I have tested with your code and changed the version of the custom property uMyVesion in my stack.
It's the same problem.
Best
Boris
My application "GeoMaths" is available on Itunes and Google Play !

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Upgrade App lost data

Post by jmburnod » Sun May 04, 2014 11:03 am

Salut Boris,
It's the same problem.
Yes. If you write changed data in your stack tMainStackPath and if you replace it
with your engine folder stack you lost data
Maybe exchange will be easier in french by phone :D
https://alternatic.ch

sirobchGA0cda
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 47
Joined: Wed Dec 21, 2011 10:42 am
Contact:

Re: Upgrade App lost data

Post by sirobchGA0cda » Sun May 04, 2014 11:07 am

Salut Jean-Marc,
Yes I will call you it's better.
Boris
My application "GeoMaths" is available on Itunes and Google Play !

michel_bujardet
Posts: 45
Joined: Mon Apr 21, 2014 10:41 am
Contact:

Re: Upgrade App lost data

Post by michel_bujardet » Sun May 04, 2014 1:22 pm

sirobchGA0cda wrote:Hello,
I save my application data IOS with a stack launcher.
Why not use

Code: Select all

put specialFolderpath("application support") 
It will retain data between versions of an app.

Mitch
http://FontMenu.com

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Upgrade App lost data

Post by Klaus » Sun May 04, 2014 1:49 pm

michel_bujardet wrote:Why not use

Code: Select all

put specialFolderpath("application support") 
?
Because this is not available on iOS? 8)

sirobchGA0cda
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 47
Joined: Wed Dec 21, 2011 10:42 am
Contact:

Re: Upgrade App lost data

Post by sirobchGA0cda » Sun May 04, 2014 2:41 pm

Thanks for the suggestion, but it's not working.
Best
My application "GeoMaths" is available on Itunes and Google Play !

michel_bujardet
Posts: 45
Joined: Mon Apr 21, 2014 10:41 am
Contact:

Re: Upgrade App lost data

Post by michel_bujardet » Sun May 04, 2014 7:10 pm

Klaus wrote:
michel_bujardet wrote:Why not use

Code: Select all

put specialFolderpath("application support") 
?
Because this is not available on iOS? 8)
Sorry. I use to do that in Mac OS X and assumed too quickly it existed on iOS. Then why not use a folder in the library, as advised in the Dictionnary...
For iOS systems:
library - The folder in which the application can store data of various types. In particular, data private to the application should be stored in a folder named with the app's bundle identifier inside library (this folder is backed up by iTunes on sync).

Mitch
http://FontMenu.com

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Upgrade App lost data

Post by jacque » Sun May 04, 2014 7:32 pm

If I understand the problem right, the data works fine until the app is deleted.

On Android, and I think iOS too, deleting an app removes its data files. That's just how the OS works. If you are updating an app from the App Store then the data files will remain, but when you are testing locally and you delete the app, any files the app has created are removed.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Upgrade App lost data

Post by jmburnod » Sun May 04, 2014 10:23 pm

Hi All,
I think we have solved the problem for the app of Boris in french by phone.
But this question often comes back. For IOS but also for standalone
For data I use the documents folder on OSX, windows and IOS for my app EcrireEnPictos (same stack for all)
One NecessaryForMyApp folder with folders they contains txt, png and aif files.
For update I use a txt file with the num of the installed version
I compare both version number and do what is to do at preopenstack
Sometimes it is just a new standalone and sometimes I have to upgrade
contents with new files or folders
On IOS the only problem I met with this method that is get diskspace to know if there is enough space.
Kind regards
Jean-Marc
https://alternatic.ch

Post Reply