Posted By

MaRmAR on 02/06/11


Tagged

data save AIR storage adobe android EncryptedLocalStore ELS


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

Demian
jondiscipulo


Adobe AIR: Save snippets of data locally


 / Published in: ActionScript 3
 

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.

  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  

You need to login to post a comment.