Storing a simple file outside of the application specific directory (ASD)

What does "second version" mean?
It should actually mean that the second version only differs in the version code (and more functionality) from the first version, but has the same packageName (project name, e.g.: myHealth.aia). Otherwise it would be a new app.

Show your blocks (especially where you store data, TinyDB).

My app consists of 2 screens. Screen1 Enables entering, changing, and searching measurements, ScrMyData handles the basic data. Screen1 has > 2200 blocks, ScrMyData has > 600 blocks. Therefore I only include snippets here.
I have now changed all file related properties to shared:
grafik
grafik

Here the respective blocks for the storing of the file:
grafik
grafik
grafik

I now get Error 908: the permission WRITE_EXTERNAL_STORAGE has been denied.

Set DefaultFileScope to Legacy in the Designer:

grafik

and post your blocks again in high qualitiy, see here (point 3).

1 Like

Creating the file works now after I changed the file and path to:
grafik

Thank You!

Sorry, that was an error. It produces Error 2103: The file /storage/emulated/0/Documents/BE_Dokuv00_01.txt could not be created.
So still unsolved.

Post the aia or a test aia.

And here my blocks in better quality:
grafik
grafik


grafik

Yes, the File component needs a relative path, see here: Some basics on Android storage system.

1 Like

I changed it, butI still get Error 2103

Please find the aia below:
BE_Doku_v00_01_04.aia (107.3 KB)

Since the text file was already created with the Companion App (i.e. another app), the file cannot be deleted or recreated (saved) with the APK. The file name must be changed beforehand.

Try this:
grafik
and do not run the app with Companion. Just build the APK and try.

Note:
You can also add a timestamp to the filename then it would work with Companion and the APK too.

1 Like

This was successful. But for some reason or another the File.Delete doesn't work or I have misunderstood it. I did the following
grafik
Do you know, what happened or is wrong?

Did you try it with the APK or Companion?

I used the apk. (And I wrote the second 'If', because I suspected that my delete statement doesn't work as I expected.) BTW I also tried it with FileScope Legacy. Then the file was not found - as expected.
Coding it as I posted, the error label looks like that:

File exists
File deleted
File exists anyway

That's why I'm asking

@Briefmark, unfortunately you ignored my previous answer

as well @Anke's question

so if my understanding is correct, what about just using TinyDB?
Taifun

It should work.

  • What is the file name and was the file created (with the APK)?
  • Did you change the project name (aia)? (If so, then it would be a new app that cannot access the file.)

EDIT:

  • Did you uninstall the app beforehand? If so, the reinstalled app is also a new app that cannot access the file.

@Taifun: Yes I'm aware that there are alternative solutions, but I found the simple file solution the most sympathtic. It's not the most elegant, I have to admit. But when I stumbled about my Delete.File issue, I wanted to clarify, what went wrong.
@Anke: The file name is:
grafik and I created it with the apk.
I didn't change the project name, but I disinstalled it and the installed it again. Could that be the reason?

Ok! That's an explanation. Thanks!

1 Like

Yes, as I already said: