Saving data
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 35
- Joined: Sun Feb 02, 2014 12:20 am
Saving data
So I'm almost done with my app for an android platform. My app basically stores data day by day according to what the user inputs in the app. I just came to realize that when the phone is restarted, turned off, or the app is cleared from active apps.....all the data stored on the app is gone!! :/ Is there anyway to prevent this from happening?
Re: Saving data
Hi Ferhan,
Nope
You have to store the data somewhere;
and reload it on startup.
Simon
Nope

You have to store the data somewhere;
Code: Select all
on mouseUp
put specialFolderPath("documents") & "/Data.dat" into tFile
if there is a file tFile then
put url ("file:" & tFile) into tData
answer tData --show the contents of the file
else
answer "No data file located" --First run
end if
end mouseUp
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- Posts: 35
- Joined: Sun Feb 02, 2014 12:20 am
Re: Saving data
Simon wrote:Hi Ferhan,
Nope
You have to store the data somewhere;and reload it on startup.Code: Select all
on mouseUp put specialFolderPath("documents") & "/Data.dat" into tFile if there is a file tFile then put url ("file:" & tFile) into tData answer tData --show the contents of the file else answer "No data file located" --First run end if end mouseUp
Simon
Hey Simon,
yeah i figured....was hoping for a miracle haha..
hmm is it okay if you clarify the code you have written? I'm not too sure what's going on...what button is being pressed? and the content is a bit confusing...not quite sure what is happening. thank you
Re: Saving data
OK here it goes
put specialFolderPath("documents") & "/Data.dat" into tFile
This is where the files are stored on mobile, Data.dat is just a filename
if there is a file tFile then
put url ("file:" & tFile) into tData
Go get the file if it is there.
So you have a game with a high score
each time you score a point you add it to tData
Normally I'd say when you close the app write tData out to a file but for mobile I say just write it every time a score is made.
put tData into url("file:" & tFile) (tFile may be a global)
Do you see how it works now?
Simon
Edit oh... yes you'd look for the file on openCard or somewhere
put specialFolderPath("documents") & "/Data.dat" into tFile
This is where the files are stored on mobile, Data.dat is just a filename
if there is a file tFile then
put url ("file:" & tFile) into tData
Go get the file if it is there.
So you have a game with a high score
each time you score a point you add it to tData
Normally I'd say when you close the app write tData out to a file but for mobile I say just write it every time a score is made.
put tData into url("file:" & tFile) (tFile may be a global)
Do you see how it works now?
Simon
Edit oh... yes you'd look for the file on openCard or somewhere
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!