Skip to main content
Known Participant
September 7, 2014
Answered

Should I use SharedObjects?

  • September 7, 2014
  • 2 replies
  • 769 views

Hi all,

I'm making a desktop based program where I will need to save a lot of user information, and I am trying to figure out if SharedObjects is the answer. I do not plan on moving the application once it is installed on the user's computer either. I have a few questions:

  1. Does a shared object file get deleted when you uninstall the Adobe Air program from the computer? If not, when does the file get deleted?
  2. Is there a size limit for the shared object file that you create? I know for web applications, the adobe player prompts the user if more space is needed (I think default is 100K).
This topic has been closed for replies.
Correct answer User Unknow

I have little to no knowledge about JSON. I would assume a regular .text file would work just fine for me, and maybe create a new .text file for each website and delete the file for each website if the user deletes it from the Air program. My main concern if I use only 1 file to store all the data is how to correctly add more data to the file, or remove data from the file and also retain the other website data that the user is not wanting to delete. I'm sure I'll have to use some type of search function and some other logic which I can see getting messy. So I think creating a separate file for each website will probably be the easiest route maybe...


In your case find some Adobe AIR SQLLite tutorials

2 replies

User Unknow
Legend
September 8, 2014

I don't suggest to use SharedObject for desktop and mobile because it's like drilling concrete blocks using a finger.

Use File and FileSteam api instead. It's opens really full powerful of Adobe AIR.

rs14smithAuthor
Known Participant
September 8, 2014

Anton, thanks for your input. What file type do you believe is the easiest to work with? XML, .Text, etc.? The type of data I will be storing will be also inserted into a DataGrid, and I will be storing the user's website information. Example, website name, website login pass, username, etc. associated with each website. So you can think of each website having it's own array of data that I need to store somewhere and constantly update the file I put that data in, and sometimes delete that website info from that data file.

So the easier to do this, the better. KISS

User Unknow
Legend
September 8, 2014

Most easy it's JSON in case you are storing only text data.

var userInfo: Object = {};

userInfo.userName = "Anton";

userInfo.age = 29;

// saving

filestream.writeUTFBytes( JSON.stringify(userInfo) );

// loading

var loadedData : Object = JSON.parse(filestream.readUTFBytes(filestream.bytesAvailable));

This model will save and load Object via JSON. I use it everywhere because it's more easy to manipulate.

Don't store Password in string format without encoding. I use in my app only md5. When user type own pass - it's converted to md5 and I'm comparing to stored past time in md5 and verify it.

Images and etc you can save using File + FileStream directly in PNG/JPG format.

1) Create use File.desktopDirectory.resolvePath("MyApp/"); folder with your app data

2) Create for each website folder in MyApp folder so 1 site it's 1 inlcuded folder

3) Save config there in JSON and put any other binary data in that folder so you newer will mix different files from different sites

File allow to generate HUGE files. Last project allow me store 2gb files.

Inspiring
September 8, 2014

I am using Shared Objects to save settings for a desktop app, mainly for compatibility reasons as my app works from browser, on desktop pc/mac and on mobile and Shared Objects let me not worry about file system differences, locations and so on.

The shared objects files won't be deleted on uninstall on desktop. You'll probably be using a custom installer so depending on the installer's features you could write a custom script to run on uninstall and clean the files if you want to. On iOS the SO are saved with the app and will be removed on uninstall. I'm not sure about Android.

As for size limit, if you need more than a few KB, you probably shouldn't be using shared objects. They are useful for saving settings, like browser cookies or the settings saved in Windows Registry, not for data storage. I don't know if the 100 KB size limit applies for AIR apps but I would assume it does.

rs14smithAuthor
Known Participant
September 8, 2014

That's my same reason I would like to use shared objects if possible. It's hard for me to determine how much data I will need. Does the 100KB limit apply to all your shared objects files you create as a group, or is it on the file to file bases?

For example, I may create a SO file named data1, and then another called data2.

Does data1 have it's own 100KB limit, and data2.sol have it's own 100KB limit?

Or

Does Adobe Player look at both data1 & data2 and say that the sizes combined have to be 100KB?