This is based on the assumption that the ASD is the same as the private directory. Taifun says this is not so, so I found a path for the private directory somewhere (one of Anke's posts?):
/data/user/0/appinventor.ai_mickofemsworth.FE3/files/test.txt
which resulted in a different error: "failed to find configured root that contains .../data/data/app...
I also tried putting
storage/emulated/0/Android/data/appinventor.ai_mickofemsworth.FE3/files/test.txt
in TextBox1_SaveFile - this produced a file could not be created error.
I'm slightly confused about which discussion you are referring to. One of your posts is about saving a file called /test.txt or /a.txt. This isn't a problem because I can share using /sdcard/test.txt. The problem is when there's no / so the file is stored in the app's private directory.
but this does not work. I'm not sure what you (Taifun) mean: I only found three blocks in Anke's extension. I tried running the create ASD directory block before the SaveFile block but that still led to a could not create file error.
I have just tried this by putting t1 in TextBox1_SaveFile in the app with the blocks in post 20 above, and
/Android/data/appinventor.ai_mickofemsworth.FE3/files/t1
in TextBox2_ShareFile.
Have I got this right? I'm afraid it doesn't work.
(I'm not using the AI Companion and Do it because this just adds another layer of complication, and by putting suggestions in textboxes I can easily check if something works.)
Thanks for your help!
you are currently using the community as debugger... and you started asking on Oct 22, now is Nov 6...
using the companion app and Do it would help you to find out what you are doing much faster (in minutes not in days)
Many thanks Anke. The apk seems to work as I can share the file and it is not saved in the root directory. I initially thought that as the file saved is /filename.txt (with the /) it would be saved in the root directory which will not be allowed in later versions of Android. But I'm obviously wrong. I will use your blocks to experiment when I've got more time tomorrow. Thanks again!
I really thought I'd tried the suggested path for saving in pre-10 versions of Android, but I obviously made a mistake because it works today. I think I've got the hang of it now. I'll post a summary of the answer to my original question in the next day or so.
In the meantime I've got just one further question - where do I find the ApiLevel block?
So the answer to my question is that I can't share files in the app's private directory, but I can share them from the app specific directory. To do this I need to save a file as
/filename.txt in Android 10
and as
/Android/data/appinventor.ai_mickofemsworth.FE4/files/filename.txt in earlier versions of Android.
In both cases the file path for sharing is
/storage/emulated/0/Android/data/appinventor.ai_mickofemsworth.FE4/files/filename.txt
(The app name is FE4 and my username is mickofemsworth.)