Deleting text in a txt file without losing the file (using a Bluestacks emulator)

Hey everyone, Im trying to link python and the appmaker together and basically the only part i dont understand is how you can delete text lines in a text file?
As in i have a text file that my python code writes some info in and the app in his turn takes whatever is written in there and displays it, when a button is pressed i need it to delete all the text lines in that file but leave the file itself intact. Is that at all possible or not?

Thanks in advance

1 Like

can you show me your block ?

1 Like

Sure, im a bit of a novice when it comes to this so please be gentle :sweat_smile:

You can't write in the assets (it's read-only):
//Test.txt

You have to copy the text file to the external storage (best to the ASD) first (using e.g. the TaifunFile extension: https://puravidaapps.com/file.php).

i have downloaded this extension, i cant find a way to read with it since i also need that

You use the built-in file component to read files.

Use the File extension to carry out file operations such as copy or move or listing a directory of files

Or use the EFile extension from @vknow360 to avoid READ_/ WRITE_EXTERNAL_STORAGE permissions.

1 Like

But my python code writes a file, the app needs to read said file and when i press the button it changes the file to say Done. Is there no way to do that?

now i get permission denied, how do you give those permissions?

Use this block:
image

i ask permission to what? ask it to the directory or?

You can find it in Screen blocks:

yes i am blind, didnt see the purple block. Can you tell me what i need to adress to get the permission? now it looks like this

What about reading the description of the ext.

grafik

Search the forum first next time.

Sorry for that, i got the permissions now.
What happens now is when i start the app it reads whatever is in the //test file, and then copies whats in there to the external /test file. However another program needs to be able to write something in the external file, which is possible. But i cannot copy whatever is in the external file to the internal one because you cant write there. Iv been looking for this on the forum but dont understand half of whats being said in these discussions

Why do you want to write in the internal storage?
As I said it's not possible to write in the assets, but you can write in the Private dir (in the internal storage).

See also here:

I dont want to write in the internal storage since its not possible, im trying to make a python code type something in a txt file and make the app scan said file every 5 seconds to and to display what has been posted

Ok, so where exactly is the problem?
So post your new blocks and show us exactly where you are stuck.