Hi,
I am working on a simple beer application that catalogs beers. Basically each card is a clone of a template card that has a bunch of fields and sliders that contain information about a beer and it's flavor profile. Also a next, previous, delete, and new button. My question is: How do I get my android app to save user entered field data on card created within my app. It saves until I close the program, and upon reopening all my changes have reverted...
I tried using a substack that opens on openstack, but perhaps I am doing something wrong......
edit: looks like I'll have to use an SQLite database?
Thanks,
SefroJones
Save field data in android
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
-
- Posts: 1201
- Joined: Sun Apr 24, 2011 2:17 am
Re: Save field data in android
Yes.
I do recall being able to save your data to another stack.
Since you can't save the Main Stack while the script is executing, etc.
Kinda cool.
The more traditional way for multiple records is to use a DB.
Saving multiple records, reading multiple records, finding multiple records, etc.
And you'll be ready to add multiple talbles.etc
If you haven't already started, perhaps start in the LiveCode lesson below:
how-to-create-and-use-an-sqlite-database - (included specific instructions for Android)
http://lessons.runrev.com/s/lessons/m/4 ... e-database
It has an example app at the top.
There is also a specific section for
Android Standalone Settings
and Deploying to Android.
hth
I do recall being able to save your data to another stack.
Since you can't save the Main Stack while the script is executing, etc.
Kinda cool.
The more traditional way for multiple records is to use a DB.
Saving multiple records, reading multiple records, finding multiple records, etc.
And you'll be ready to add multiple talbles.etc
If you haven't already started, perhaps start in the LiveCode lesson below:
how-to-create-and-use-an-sqlite-database - (included specific instructions for Android)
http://lessons.runrev.com/s/lessons/m/4 ... e-database
It has an example app at the top.
There is also a specific section for
Android Standalone Settings
and Deploying to Android.
hth
Last edited by BarrySumpter on Sun Apr 08, 2012 10:53 pm, edited 6 times in total.
All my best,
Barry G. Sumpter
Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.
Barry G. Sumpter
Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.
Re: Save field data in android
Hi SefroJones,
Hint:
Substacks of a standalone can also not be saved, just like the mainstack!
For small amounts of text, like in your case, there is no need to use a database, I think!
You can write the content of your field(s) to a simple textfile in the users "documents" folder,
where you have write permissions! Then read that file in again when the app starts the next time.
Something like this basic example:
Execute "read_field" "on preopenstack" and I am not sure when to execute the "save_field" handler?
Maybe "closestack" or "shutdown", you will find out, I do not have iOS or Android license
Best
Klaus
Hint:
Substacks of a standalone can also not be saved, just like the mainstack!
For small amounts of text, like in your case, there is no need to use a database, I think!
You can write the content of your field(s) to a simple textfile in the users "documents" folder,
where you have write permissions! Then read that file in again when the app starts the next time.
Something like this basic example:
Code: Select all
## Save field content
command save_field
## Save contents of field to a text file in the users docs folder:
put specialfolderpath("documents") & "/Name of your text file here.txt" into MyPrefsFile
put fld "your field here" of cd XYZ into url("file:" & MyPrefsFile)
end save_field
## Read saved field content if present
command read_field
put specialfolderpath("documents") & "/Name of your text file here.txt" into MyPrefsFile
## Check if file is present, since ot might not have been saved yet!
if there is a file MyPrefsFile then
url("file:" & MyPrefsFile) into fld "your field here" of cd XYZ
end if
## Field is mepty by default, so no need to EMPTY in the ELSE clause!
end read_field
Maybe "closestack" or "shutdown", you will find out, I do not have iOS or Android license
Best
Klaus
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: Save field data in android
Thanks for the suggestions guys, I will be trying out both of these methods in a few hours, I'll let you know how it comes out....
-
- Posts: 16
- Joined: Fri Jun 29, 2012 8:05 am
Re: Save field data in android
Thanx Sefro jones for creating this thread & thanx to Barry and klaus too... Your discussion sorted out my problem.. I was about to create a thread regarding the same problem and I found this..... Thanx to all.....