I am trying to save and get data from an adobe air application with the following code. buts its just keep alerting only undefined. Can someone find the error?
function saveData(n, v){
var bytes = new air.ByteArray();
bytes.writeUTFBytes(v);
return air.EncryptedLocalStore.setItem(n, bytes);
}
function getData(n){
var storedValue = air.EncryptedLocalStore.getItem(n);
return air.trace(storedValue.readUTFBytes(storedValue.length));
}
saveData('item1', 'value1');
alert(getData('item1'));
try removing the air.trace
function
function saveData(n:String, v:String):void
{
var bytes = new air.ByteArray();
bytes.writeUTFBytes(v);
air.EncryptedLocalStore.setItem(n, bytes);
}
function getData(n):String
{
var storedValue = air.EncryptedLocalStore.getItem(n);
return storedValue.readUTFBytes(storedValue.length);
}
saveData("item1", "value1");
alert(getData("item1"));