Skip to main content
Inspiring
August 3, 2016
Question

Store data's in air for IOS.

  • August 3, 2016
  • 1 reply
  • 258 views

Dear Friends,

iam creating an IOS app using Air for IOS. i want to store data in txt file and retrieve it. Iam using the following code:

import flash.filesystem.*;
import flash.events.MouseEvent;
var cacheDir: File = null;
var tempDir: File = null;

//Initialize the Objects with proper paths.
var str: String = File.applicationDirectory.nativePath;
cacheDir = new File(str + "//Library/Caches");
tempDir = new File(str + "//tmp");
var fr: FileStream = new FileStream();
fr.open(cacheDir.resolvePath("myCache.txt"), FileMode.WRITE);
fr.writeUTFBytes("works");
fr.close();

btn.addEventListener(MouseEvent.CLICK, btn_click)

function btn_click(event: MouseEvent) {
var fw: FileStream = new FileStream();
fw.open(cacheDir.resolvePath("myCache.txt"), FileMode.READ);
txt.text = fw.readUTFBytes(4);
fw.close();
}

it works fine in my desktop. when i compile and intall in ipad, it is not workign pls help me what should i do to make it work. i want to store data's in Ipad..

Thanks in Advance,

Syed Abdul Rahim

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
August 4, 2016

use a sharedobject, not a text file.