priya
priya

Reputation: 468

saving file to phone documents using codenameone

I am zipping the app files and I want to save it to the phone documents in iOS. How I can achieve this using root_type_mainstorage in codenameone?

I am struggling with this.

Upvotes: 2

Views: 84

Answers (1)

Shai Almog
Shai Almog

Reputation: 52770

There is no shared storage in iOS so I'm not sure what you are trying to do. This will write a file to the file system in iOS. Notice I'm assuming that you have this line in the import:

import static com.codename1.ui.CN.*;

You can then do:

String fileName = getAppHomePath() + "MyFileName.txt";
try(OutputStream os = openFileOutputStream(fileName)) {
    os.write(text.getBytes("UTF-8"));
} catch(IOException err) {
    Log.e(err);
}

Upvotes: 0

Related Questions