HOWTO: Get Application Specific Directory -ASD (where one exists) without Extensions

A little trick/tip....

  1. Drag out a canvas to your project, set it to 1x1 pixels in size, but keep it visible.
  2. Drag out a File component
  3. Use these blocks...

Works in Companion and for compiled apps, tested on Android 10
(should work across all android versions....returning the root of the sdcard in pre 10)
The ASD did not exist before Android 10.

10 Likes

Little, useful guide :+1: :grinning:

No, this works only for devices with Android ā‰„ 10.
In addition, two additional components are unnecessarily required and moreover WRITE_EXTERNAL_STORAGE is requested. In my opinion, the biggest disadvantage is that a dangerous permission is unnecessarily required for this.

Sorry, but that's not really an alternative to my little extension ā†’ GetASD.

1 Like

Ah, @Anke, your usual negative and unhelpful response of "No" !

  1. It does "work" across pre 10 (I tested on Android 7). But because there is no ASD as such, it returns the root of the sdcard. So it "works"....

  2. Yes, the canvas and file components are used, but this is required in order to negate the need for an extension and return the directory location, the whole point of the blocks. Many developers may already be using a canvas or file component in their projects, they can therefore make use of this without adding extras.

  3. By using the File component, this introduces the WRITE_EXTERNAL_STORAGE permission. I really do not see what the issue is here, a user will probably want to be reading and writing to the ASD / root of the sdcard if they need to know where it is in the first place ?

  4. It is an alternative to "your little extension", which indeed works very well, and to other extensions that offer the same functionality.

I welcome your constructive comments, but please seek to be a bit more positive in your responses. Like you, I am hopeful that soon we will have a built-in method for this, which will therefore make any such methods and extensions redundant!

TIMAI2

4 Likes

Regardless of the need to use the ASD from API 30 onwards, the main advantage of the ASD is that no READ_ / WRITE permissions are required. In this respect, as I said, it is a major disadvantage if these permissions are requested.

It is clear to me that for API < 29 with your method the root dir of the external storage is returned, but that is precisely the problem. Therefore, this method does not work for all Android versions. I would also like to know what is so problematic about the word "No", if it applies.

Btw, as you should know, I am very positive towards everyone - and especially you: Appreciation for @TIMAI2

But if something is not helpful or wrong, then I reserve the right to state it clearly, without further ado.

1 Like

Small question, is the path same for all devices (and all android versions)?

Ditto.... :slight_smile:

Here is a simple way to do it for all Android versions and without any component and permission:

getASD.aia (2.9 KB)

2 Likes

Yes, that was my first approach, but it requires you to open up an aia and look at project.properties, or look at your project details in the program, in order to enter the required information, which is then hardcoded. My approach is about being more dynamic.

Not sure what your issue is about components or permissions....?

Yes, check my aia.

1 Like

I think if you are working on a project you probably know the name of your project as well as your email address. So what's the problem?

I always try to use as few components as possible. And it is even more important for me (and especially my users) to avoid dangerous permissions. My users (like myself) don't like permissions at all.

(thread added to FAQ)

You missed out the hardcoded part....

How will you read or write anything from the ASD if you don't have those permissions in place ?

No, this is no problem in this case.

As I said several times, the ASD does NOT require any permissions according to Google (ā‰„ API 19).

It is easy enough to drop the File component, it was only there to remove an empty file, not taking up any space

The extensions-free solution is great for people looking to publish apps to the gallery. As we know, extensions are prohibited there.

Yes, but as I said the approach from @TIMAI2 doesn't work for API<29.

the solutions, which are provided by extensions (be it @Anke's extension or one of the file extensions) do not need any permissions to read or write files from/to the ASD - Application Specific Directory

to have a "solution" which needs permission to only get the path to the ASD seems not very helpful...
and we are not only talking about the File.Delete method, but also the Canvas.SaveAs method...

exactly... the subject of the discussion is "Get ASD without Extensions" and as @Anke already explained, you do not get the ASD for devices < Android 10, you get the root directory...

usually users try to write an app with as less permissions required as necessary

Taifun


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

3 Likes

But if you are creating an application for school or to be placed in a gallery, nobody cares about the lack of permissions, the application is only supposed to work. If someone is creating an application for Google Play, it is of course recommended to have as few permissions as possible.

Yes, maybe. But again: the main problem here is, as I already said, that it doesn't work for devices with Android < 10.