Can not write text file

Please explain exactly what the goal is (what should be achieved):

  1. Read the text file (appunti.txt) from the assets (at Screen.Initialize ?).
  2. Save the text in the new file (appunti.txt) in the Private dir.
  3. ...
  4. ...

my goal is to avoid error on first run

  1. Read the text file (appunti.txt) from Private dir
  2. if not exist (screen error) save the text in the new file (appunti.txt) in the Private dir.
    then add text and save

Which text?
Where does the text come from since the text file does not exist on the first run?

textbox text to create file

So this textbox is not empty at the first run (at Screen.Initialize)?
Post a test aia to shorten this conversation.

Try this: copyTextToPrivateDir.aia (34.8 KB)

your project runs well, but i think this attached too
APPUNTI.aia (13.3 KB)

@Anke, thanks for all suggestions, the best solution for me is this

Okay, if you feel that is the best solution, you should close this topic by pressing the solution button in that post.

I'm beginner, I'm waiting for comments, it's the best for me, but maybe there are some bugs I can not see.

So actually what functions do you want for your app.

And also see this :
http://ai2.appinventor.mit.edu/reference/components/storage.html#File

read/write a textfile

I see you want to create a Note App but use the functions of the text file right?

You are right, but i just want to know if my approach is correct

Try my new Note App project, it might be very helpful :
NoteApp.aia (6.1 KB)

Note :

  • This App saves data using Component (File).
  • If You Get Bugs Or Errors, please let me know.
  • If this project is successful without any bugs or errors, I will make a topic for this

Regards,
Salman Dev

Thank you for your app, but I would like to know if my approach is correct to read, edit and save a text file. I want to learn and not copy others' code

Yes you can do it like that. The Screen1.ErrorOccured event is only triggered when the app is started for the first time.

Ok, thanks a lot for all your suggestion

yes, I have done that in my project, so my project won't bring up that error again because I didn't put the (Read File) block on (when screen1 open) so the (Read File) block only works when you have saved data.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.