Get the path of → ASD (app-specific dir) & → private data dir (internal storage)

Hi Anke,

thank you very much for sharing.

Unfortunately, I'm not an expert user, so I have some difficulties to understand all the applications that you extension could have.

So please, a question for you:

I'm trying to write a camera app, using the ProCam64 extension. Currently, my app can save a picture into the folder /storage/emulated/0/DCIM/MyFolder (so we are into the internal storage). But I can't read the same picture and load it as preview, maybe due to permissions (the app could read picture if it is stored into the ASD).

I read above that your getASD extension could store any kind of files in internal storage. So, could your extension help me in some way? If yes, how should I use it?

Thank you so much for your answer, kind regards.

Try to request READ_EXTERNAL_STORAGE permission (e.g. in the Screen.Initialize event).

I just tried your suggestion. Unfortunately, it didn't work.

Because I have also the Camera permission to request, I tried to write a "do" cycle, but by requesting the first permission in the Screen.Initialize event, and the other ones in the Screen.PermissionGranted event.

If Camera permission is requested in the Screen.Initialize, the app request also the second permission (READ_EXTERNAL_STORAGE), and it freezes when I allow it.

If READ_EXTERNAL_STORAGE is requested in the Screen.Initialize, the app starts but without asking for any permission. It seems like if READ_EXTERNAL_STORAGE is not allowed and so the Start.PermissionGranted event is not called. Obviously the issue of load the picture is not solved.

However, maybe I will open a new topic, I think we are off topic here, isn't so?

Thank you for answering me.

Post the aia (or a small test aia). It shouldn't be a big deal to solve this problem...

FolderCamera (1).aia (36.7 KB)

My device is a Xiaomi Redmi Note 8 Pro, with Android 11.

Try this:

Many thanks for you effort Anke. But also this one is not working.

The first time I open the app, it asks for Camera permission. The second time, for the storage permission. Then, when I take a picture, it doesn't save it.

FolderCameraAnke.aia (41.4 KB)

Always show your blocks as well.

Remove the space after "FOTO- ": :face_with_monocle:

... and always debug your blocks. Then you would most likely have noticed this error yourself.

I checked several times the blocks, but I was too focused on the blocks to be equal to your suggestion, not on the strings, and I didn't noticed that mistake. Sorry Anke, I really apologize for this.

However, now the app saves the pictures, but the issue about the permissions is unchanged. As you suggested, is there some tools for debugging?

See here (point 4):

:question:

use Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools
Taifun


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

Do files uploaded in the Media panel in AI (example below) go to the ASD? If so, should I be able to access them through the ASD Path? For example, if I wanted the path to the model.json file uploaded in Media, would it be /storage/emulated/0/Android/data/<app_package>/files/model.json?

(I'm asking this because as of now I cant access them through this path, Java fires a java.nio.file.NoSuchFileException exception).
image

No, files from Assets don't go to ASD.

You need to first copy files from assets to ASD then you can access them from path of that file.

You can use Copy Assets files block from ASD Downloader extension.

@The_K_Studio great extension! Worked wonders, thank you so much.
Is this extension by any chance open source?

@Anke is your extension open source?

No, only with Companion. With the compiled app (APK, AAB) files in the assets are in the internal storage. File in the ASD are in the external stoarge.

See also:

1 Like

Everytime I try to import this extension, I get an error saying the DatePicker control can't be found and builds fail. If I remove the extension, the app works. Weird.
I AM using the date picker in my app.

Try this simple app:
GetASD_DatePicker.aia (6.2 KB)

(No issues here.)