Application specific directory

I’m sure I’m missing something here but I can’t find what.

I’m using @Taifun file extension to be able to write a file (an image to use as sprite) without asking permission in the app specific directory but when I get to the point where the canvas saves the image, it says the app doesn’t have permission. So obviously there’s something I don’t understand here.
Can anyone point out what is it?

Here the directory is created:

And here (a different screen) the file should be saved but it shows the permission request, and after I grant the permission, it shows error 908. I understand it shouldn’t need to ask for permission right?

1 Like

What happens if you write the path instead of using the ApplicationSpecificDirectory block when saving or setting the image?

1 Like

See here:

2 Likes

I am not able to describe it correctly but I will try.
App Inventor uses a lot of util classes to shorten long and repeated lines of code.One of them is FileUtil.
Canvas uses that to save file and (I don’t know why) FileUtil asserts Write permission to Form.
This is similar in Image component also.It uses MediaUtil class to set image which automatically asserts Read permission to Form.
You need read permission even when you want to load image from URL.:laughing:

2 Likes

In that case the app will require permission to access the external storage and I want to avoid that. Is just a game I would like to keep it clean for the user, so they don’t suspect anything wrong about it. If I require access to their storage, I see in the reviews people don’t like that in games.

1 Like

Ok, well. In a way is good to know I got it right and it wasn’t my mistake. I really though my inexperience with files was rearing its ugly head again! :grin:

1 Like

Thanks for that explanation! I’ll see if I can do what I need to do in a different way then.

1 Like

I’m sure they don’t like it at all, in any app. And I feel the same way.

2 Likes

Btw, my very first post in the Kodular forum was about this topic at the beginning of 2019.

1 Like

In one of my projects, I save the students handouts in the ASD.

I write the path to the ASD and it doesn’t ask for permission. :thinking:

1 Like

Would you mind showing the blocks you used for that?

001

002

1 Like

So when saving you typed the path manually instead of using the block that returns the path.
I might try that.

But according to @vknow360’s explanation, I think this problem only happens when using the canvas or image component. Is that right?

1 Like

For some components you need the relative path (e.g.: File comp.): Private & app-specific directory - permissions

1 Like

Yes, that’s what I meant.

So, would that not happen because I’m using the TaifunFile for coping?

003

2 Likes

Exactly, see in the extension description: App Inventor Extensions: File | Pura Vida Apps

2 Likes