Software Archive
Read-only legacy content

I/O files

Cooper_M_
Beginner
1,029 Views

Hello,

I've been attempting to create a file via XDK. I wanted to try and get better understanding of how to create file and even read files. I used lot of resources found on internet. Few includes the following: 

https://developer.mozilla.org/en-US/docs/Web/API/FileSystem
http://www.html5rocks.com/en/tutorials/file/filesystem/

I tried my best to understand and create an app using XDK. With or without Cordova - I'm very new with this program AND creating an app too. So I can't seem to get this to work. I'm feeling frustrated, especially a week after working on same thing over and over as well as creating few programs to start over to try to backtrack and see what could be going wrong. All leads to same/similar error relating to 'root being undefined'. 

I don't know how to proceed at this point. Could someone maybe make an file so I can read and see how it's done? I've been doing 'copy/paste' from few sites to try and work with given code to understand it but nothing seems to work as I said. I don't want to seem lazy, but I am stumped on how to get around the errors... 

Thanks

0 Kudos
6 Replies
Chris_P_Intel
Employee
1,029 Views

What, ultimately, are you hoping to do?  

Do you simply need to store and retrieve some information?   Are you hoping to write a specific file, if so what and why?

 

0 Kudos
Cooper_M_
Beginner
1,029 Views

Ultimately, I want to learn how to either create new file or write into already created file as well as reading from a file that was either previously created by me or already is there on app from other functions. I want to understand how to write a file and read it. That's all I want to understand. I am fine with writing a new file that is named "readme.txt' but is blank text. I just can't do that on my own for some reason and I don't understand why it doesn't work. 

I'm not asking for super fancy i/o function. I just want to have some kind of file I can look and read. To see why the one I made didn't work. 

0 Kudos
PaulF_IntelCorp
Employee
1,029 Views

File I/O does not work that well in the Emulate tab, if that is where you are trying to do this...

See the docs for the file plugin, in particular, this section: https://github.com/apache/cordova-plugin-file#where-to-store-files that should help you get started.

0 Kudos
Cooper_M_
Beginner
1,029 Views

Paul Fischer (Intel) wrote:

File I/O does not work that well in the Emulate tab, if that is where you are trying to do this...

Would it work if I ran it on my iPad to test the app? Or same problem, not working as well? I've been using emulate tab assuming everything would work just as well as running it on iPad, so I did not try that. 

0 Kudos
PaulF_IntelCorp
Employee
1,029 Views

If you want to confirm proper behavior of your app you must run it on a real device. The Emulate tab is good for basic logic debugging in your app and simple visualization. However, running on device is the only way you will understand if your app actually works. The Emulate tab provides some simple and convenient simulations of some basic Cordova APIs, but it does not represent the full behavior of a real device.

I highly recommend you use the Debug tab for the best test and debugging experience. Ultimately, the most accurate test is to run a built app on a real device. But the Debug tab will get you very close, much closer than the Emulate tab will.

0 Kudos
Cooper_M_
Beginner
1,029 Views
Okay. Thank you. I will start using both debug and test tabs. I thought emulate would give me some result. I was wrong. I appreciate your inputs.
0 Kudos
Reply