Permission causes app to crash?

Hello, I have a problem when trying to save data to a file that it pops up asking permission to save it and once I accept or deny it crashes the app? It works if I do it but still crashes the app? .

I looked at some similar posts here and I have all the defaults set to legacy storage and the scope to legacy but the app still crashes for some reason

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

Sorry I just didn't think the blocks were needed as like i said in the post the code all works it just crashes the app when it asks for permission to save/access storage.

But as you requested them, here they are:



how did you set the default filescope in the Screen properties?
how did you set the file scope for the file component?
which Android version are you using for your tests?

Taifun

I did say in the post that I set the default scope properties on screen 1 and the file component both to legacy. And I check to see if the file saves and I'd read okay after restarting the app and both worked.

I tested on android 10 and android 12

what happens if you set the file scope of the file component to "App"?
Taifun

Files is no longer able to be found when I try import it even though I can see its there so it kinda stops everything working when set to app

where is the text file ? please attach aia for testing

attached is the aia if you want to test, export and import is located on the settings2 page

I would test a simple aia with the problem you have, not an aia with many screens.

1 Like

you have to start your tests from the beginning... store the file in ASD (using file scope App) and read it from there
file scope should be App
default file scope should be Legacy

you can access the file for example using total commander, see also

Taifun

The problem is I can see the file but the app can no longer find the file when it's stored using the app path

are you testing using the companion app? just delete the file and restart your tests
first store it in ASD and then read it from there

Taifun

Nope I am using the downloaded app. I see the file stored in the apps directory under files. Yet when I try to read the file it says it can't find it. It's searching for the same file name in the same folder. I tried deleting the file and restarting the process, same thing.

Yet when I had the scopes all set as legacy it was able to find the file fine and it was stored outside of the app directory

follow @patel 's advice

and if you still got issues with the test project as small as possible, then post it here into this thread, so someone can take a look

try to read it only with the filename PVBackup.txt (i.e. without leading slash)

Taifun

I am sorry but how would that change anything ? The rest of the app works fine and has been working fine for a while. This is the only new addition so the only problem can be in the reading and writing the file and an issue with accessing the ASD. After reading a few other posts about the file component it seems you can't read a file from the ASD anymore from what I understand so I will have to go back to using legacy and just try to figure out why accepting the permissions causes the app to crash.

Yes I tried without the / as well. Same issue.

well, if something is not working, someone else can take a look at your simple test project...
I myself will not download a complex app to do some bug hunting, but probably you will find someone else, who likes to do that...

this is incorrect

Taifun

OK I still don't understand the reasoning about the aia file but okay I must of misread/understood the post I was reading about reading from the asd.

Well I thought I would try one last thing which was to clear the app data and uninstall completely then re download it(instead of pushing updates to the app) and now it's decided that it wants to work. So I have no idea but it seems to work now?

Everything you said in this thread makes no sense at all.
I took a closer look at your aia. In this aia you set DefaultFileScope = App and also FileScope = App (and both permissions READ / WRITE enabled in the Designer for the File component). This means that all files saved via the File component are saved in the ASD (under all Android versions. However, READ & WRITE permissions are only required for Android < 4.4 (API 19, KitKat).

So I removed the Solution marker (from your post #19) because uninstalling and reinstalling the app is definitely not a solution. This will only confuse others (and obviously yourself, by the way).

See also here.