Adobe AIR: Save snippets of data locally


/ Published in: ActionScript 3
Save to your folder(s)

Adobe AIR offers an ability to save small snippets of data locally (eg. users' settings). Works also on Android. EncryptedLocalStore is stored encrypted using AES-CBC 128-bit method. It is not recommended to store more than 10 MB of data because of reading/decrypting speed of AIR.


Copy this code and paste it in your HTML
  1. // To save variable to ELS (EncryptedLocalStore)
  2. var str:String = "Bob";
  3. var bytes:ByteArray = new ByteArray();
  4. bytes.writeUTFBytes(str);
  5. EncryptedLocalStore.setItem("firstName", bytes);
  6.  
  7. // Read it from ELS
  8. var storedValue:ByteArray = EncryptedLocalStore.getItem("firstName");
  9. trace(storedValue.readUTFBytes(storedValue.length)); // traces "Bob"
  10.  
  11. // Remove it from ELS
  12. EncryptedLocalStore.removeItem("firstName");
  13.  
  14. // Remove EVERY data from ELS
  15. EncryptedLocalStore.reset();

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.