Android Question Help -How to export and import text files to a user defined directory under Root/download

kps

Member
Hello all,

This is my requirement.
I need a simple code snippet to export text data to text files to a user defined directory under Root/download.
After making changes to that exported file in any android text editor, import that file back in the app to use the modified data.
The code should be in a separate module. I should be able to use the functions in the code module in my main module.

I have checked the forum for code snippets. The relevant threads are old.
This one comes very near to my requirement but not quite.
https://www.b4x.com/android/forum/threads/📌-b4a-save-a-file-to-the-download-folder-and-document-pictures-music-movies-dcim-folders.165408/

I thought it should be a simple matter for AI chatbots. I have tried Chatgpt, Claude, Perplexity and even Z.ai.
They kept going round in circles with various errors, patching those errors, trying different approaches and ending up without any clue.
No one has been able to come up with a simple and reliable solution. The initial solutions work but fail with rigorous testing.
The app crashes at various points. It it works in debug, doesn't work in release. If it works with permission granted in a previous trial, it crashes if the app is uninstalled and re-installed. Everyone finally comes to the conclusion Google has tightened the requirements and old methods don't work any more.

I am perplexed that a very basic requirement like this has been so difficult to achieve.

Any one to come to my rescue?
 

Mark Stuart

Active Member
Licensed User
Longtime User
Hi, check out Erel's Text Editor app. Search for "Text Editor".
In that app it shows how to save a file and also to read in the same file.
The user gets to select which folder in both cases.
Mark
 
Upvote 0
Top