Unable to get a saved data in adobe air ELS

丶灬走出姿态 提交于 2020-01-07 02:46:07

问题


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'));

回答1:


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"));


来源:https://stackoverflow.com/questions/13212992/unable-to-get-a-saved-data-in-adobe-air-els

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!