Can not write text file

I can read my file but not save changes

do you mean old data is not stored?

You cannot save new data to a file stored in assets. You will need to copy the file to your sdcard/ASD (application specific directory) and use it from there.


Why I can update a tinydb but not a text file ?

Because the tinydb and its files (xml) are created at runtime and stored in the private ASD for the app, where it is read/write able

So instead of using a text file I could use a tinydb with only one tag

Please explain what you mean ?

I'm sorry, only one tag, not key. I need it to write notes

How do you get the data into the tag/value for a distributed app?

Here is my idea

What is the goal?

See also here (especially → point 2):

My goal is to read/write notes into internal storage, I can not do it with a textfile, then I'm trying with a multiline textbox and tinydb.

I think this tutorial can help you :

Try something like this:

This way the text is saved in the Internal Storage:


See also here (→ point 1.2.):

Thank You Anke for suggestion, it does not solve my problem, but I tried with the following code (filename without slash) with success. Can you explain me why ?

Why? In what way?

That's exactly what I have shown.

No, this does not work the first time you run the app because there is currently no text file in the Private directory.

Yes, You ara right the first time I receive a warning, but after typing some words I can save file without problems. When I tried your blocks with 2 files I was not able to read saved words

I didn't use 2 files (only one: text.txt). I only added some text " + def`".
So where is the problem?

Maybe I can not understand your code, you save in private dir, but you read from //