[FREE] ASD Downloader Extension - Download and manage files in ASD

ASD Downloader

An extension for MIT App Inventor 2.
ASD Downloader extension to download and manage files in ASD (App Specific Directory). Developed by The K Studio.

ASD Downloader extension to download files in App Specific Directory (ASD) without READ or WRITE PERMISSION. Since ASD is always accessible to READ and WRITE files within the app starting Android 4.4 and it does not requires READ and WRITE permission.

Nowadays due to new restrictions in higher Android versions it is difficult to manage files without READ and WRITE PERMISSIONS where ASD is very useful to store downloaded files and manage them without any permission. Android version below 4.4 requires READ and WRITE Permission to download in ASD.

This extension allows you downloading files in ASD and managing them with various functions.

You can either show download system notification or you can hide it using this extension, also you can create a custom notification layout.

:memo: Specifications


:floppy_disk: Size: 22.00 KB
:iphone: Minimum API Level: 7
:date: Updated On: 2025-01-22T18:30:00Z
:computer: Built & documented using: FAST-CLI

Uses permission: android.permission.DOWNLOAD_WITHOUT_NOTIFICATION

Events:

ASDDownloader has total 12 events.

:yellow_heart: DownloadCompleted

DownloadCompletedBlock

Event triggered when the file download is completed. Provides the custom ID and file path.

Parameter Type
id number
filePath text

:yellow_heart: DownloadProgress

DownloadProgressBlock

Event triggered when the file download progress is updated.

Parameter Type
id number
percentProgress number
totalSize number
downloadedSize number

:yellow_heart: DownloadCancelled

DownloadCancelledBlock

Event triggered when the file download is canceled.

Parameter Type
id number
message text

:yellow_heart: OnError

OnErrorBlock

Event triggered when there is an error occurred during the file download. Provides the error message.

Parameter Type
errorMessage text

:yellow_heart: FileMoved

FileMovedBlock

Event raised when a file is successfully moved. Returns the destination path of the moved file.

Parameter Type
newPath text

:yellow_heart: FileRenamed

FileRenamedBlock

Event raised when a file is successfully renamed. Returns the new path of the renamed file.

Parameter Type
newPath text

:yellow_heart: FileCopied

FileCopiedBlock

Event raised when a file is successfully copied. Returns the new path of the copied file.

Parameter Type
newPath text

:yellow_heart: FileDeleted

FileDeletedBlock

Event raised when a file is successfully deleted. Returns the deleted file path.

Parameter Type
filePath text

:yellow_heart: FolderCreated

FolderCreatedBlock

Event raised when a folder is created. Returns the created folder path.

Parameter Type
folderPath text

:yellow_heart: TextReceived

TextReceivedBlock

Event raised when text is successfully received from a file.

Parameter Type
fileText text

:yellow_heart: FileSaved

FileSavedBlock

Event raised when a file is successfully saved. Returns the saved file path.

Parameter Type
filePath text

:yellow_heart: FileAppended

FileAppendedBlock

Event raised when text is successfully appended to a file. Returns the path of the appended file.

Parameter Type
filePath text

Methods:

ASDDownloader has total 26 methods.

:purple_heart: DownloadFile

DownloadFileBlock

Downloads a file and saves it to ASD or a specified path. Specify the file name with file extension, eg. file.pdf

Parameter Type
url text
fileName text
id number

:purple_heart: CancelDownload

CancelDownloadBlock

Cancels a download with the specified ID.

Parameter Type
id number

:purple_heart: IsDownloading

IsDownloadingBlock

Checks if a download is in progress for the specified ID.

Parameter Type
id number

:purple_heart: GetTotalSize

GetTotalSizeBlock

Gets the total size of the download for the specified ID.

Parameter Type
id number

:purple_heart: GetDownloadedSize

GetDownloadedSizeBlock

Gets the downloaded size of the download for the specified ID.

Parameter Type
id number

:purple_heart: GetPercentProgress

GetPercentProgressBlock

Gets the download progress percentage for the specified ID.

Parameter Type
id number

:purple_heart: FileExists

FileExistsBlock

Check if a file already exists from the given file path

Parameter Type
filePath text

:purple_heart: DeleteFile

DeleteFileBlock

Delete a file or directory (including its contents) from the ASD using the given file path.

Parameter Type
filePath text

:purple_heart: GetASD

GetASDBlock

Get the actual App Specific Directory (ASD) path

:purple_heart: CreateFolder

CreateFolderBlock

Create a new folder in the ASD using the given folder name

Parameter Type
folderName text

:purple_heart: GetFilesList

GetFilesListBlock

Get a list of files from the given path

Parameter Type
path text

:purple_heart: GetFoldersList

GetFoldersListBlock

Get a list of folders from the given path

Parameter Type
path text

:purple_heart: CopyFileAsync

CopyFileAsyncBlock

Copy a file from the source path to the destination path asynchronously

Parameter Type
sourcePath text
destinationPath text

:purple_heart: FilesListFromAssets

FilesListFromAssetsBlock

Get a list of files from the app's assets

:purple_heart: CopyFileFromAssets

CopyFileFromAssetsBlock

Copy a file from the app's assets to a specified destination path

Parameter Type
assetFileName text
destinationPath text

:purple_heart: MoveFileAsync

MoveFileAsyncBlock

Move a file asynchronously from the source path to the destination path.

Parameter Type
sourcePath text
destinationPath text

:purple_heart: RenameFile

RenameFileBlock

Rename a file from the given file path to a new file name

Parameter Type
filePath text
newFileName text

:purple_heart: ChangeFileExtension

ChangeFileExtensionBlock

Change the extension of a file to the specified extension.

Parameter Type
filePath text
newExtension text

:purple_heart: FileSize

FileSizeBlock

Get the size of a file from the given file path

Parameter Type
filePath text

:purple_heart: FileName

FileNameBlock

Get the file name from a given file path.

Parameter Type
filePath text

:purple_heart: MimeType

MimeTypeBlock

Get the MIME type of a file from the given file path. Use file path as full file path or file content URI.

Parameter Type
filePath text

:purple_heart: ConvertFileSize

ConvertFileSizeBlock

Converts a file size in bytes to a human-readable format (KB, MB, GB, etc).

Parameter Type
fileSizeInBytes number

:purple_heart: SaveFile

SaveFileBlock

Save text to a file at the given path.

Parameter Type
text text
filePath text

:purple_heart: ReadFile

ReadFileBlock

Read text from a file at the given path.

Parameter Type
filePath text

:purple_heart: AppendToFile

AppendToFileBlock

Append text to a file at the given path.

Parameter Type
text text
filePath text

:purple_heart: GetSdkVersion

GetSdkVersionBlock

Get the Android SDK version.

Designer:

ASDDownloader has total 4 designer properties.

:green_apple: ShowNotification

  • Input type: boolean
  • Default value: false

:green_apple: NotifyCompleted

  • Input type: boolean
  • Default value: false

:green_apple: NotificationTitle

  • Input type: string
  • Default value: Downloading File

:green_apple: NotificationDescription

  • Input type: string
  • Default value: File download in progress

Setters:

ASDDownloader has total 5 setter properties.

:green_heart: CustomDownloadPath

CustomDownloadPathBlock

Set a custom download path other than the app-specific directory (ASD).

  • Input type: text

:green_heart: ShowNotification

ShowNotificationBlock

Set to true to show system downloading notification, false to keep it hidden.

  • Input type: boolean

:green_heart: NotifyCompleted

NotifyCompletedBlock

Set to true to show system download completed notification, false to keep it hidden.

  • Input type: boolean

:green_heart: NotificationTitle

NotificationTitleBlock

Set the title of the system download notification.

  • Input type: text

:green_heart: NotificationDescription

NotificationDescriptionBlock

Set the description of the system download notification.

  • Input type: text

Download

Version 7: com.thekstudio.ASDDownloaderV7.aix (37.4 KB) without ID feature.
Version 8: com.thekstudio.asddownloader.aix (22.9 KB) with ID feature

Note:
While testing in companion enable show notification to avoid error due to permission error in companion.

Documentation generated using FAST by Jewel and block images generated using Extension Docs generator by Akshat.

Leave a like if found useful :heart:

12 Likes

I've done a few quick tests and everything seems to be working fine. There are some features that my DownloadToASD extension does not provide. However, some methods require storage permissions that are not declared in the Manifest by the extension:

  • READ_EXTERNAL_STORAGE is required on all Android versions (at least before Android 13 must be targeted on August 31, 2023).

  • WRITE_EXTERNAL_STORAGE is required on all Android version less than 11.

2 Likes

Thank you for your tests.

But READ, WRITE PERMISSION is not required to manage files in ASD.

Once again:

Just a few examples:

  • .GetFileList (READ perm. on all Android versions, for listing media files)
  • .CopyFile... (to non-ASD-dir methods - WRITE perm. on Android < 11)
  • .DeleteFile (WRITE perm. on Android < 11)

I also read that there will be new read permissions for different files. Music, Pictures, etc...

1 Like

Yes... as already mentioned here:

Starting with Android 13, READ_EXTERNAL_STORAGE is replaced by 3 other (new) permissions, separately for images, audio and video:

  • READ_MEDIA_IMAGES
  • READ_MEDIA_AUDIO
  • READ_MEDIA_VIDEO

After Aug 31, 2023 (targetSdkVersion = 33) READ permission should be declared like this:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
                 android:maxSdkVersion="32" />

I will also include this and other changes starting with targetSdk=33 in my guide "Some basics on Android storage".

Is it specifically for non ASD path or for ASD as well?

:ballot_box_with_check:

1 Like

Okay, so as my extension is specially for ASD then no need to declare permission in extension to manage files in ASD

Also,

I have tried to copy a file from ASD to storage/emulated/0/Download folder and it worked without READ WRITE PERMISSION.

Yes, on Android 11+, but on Android ≀ 10 storage permissions are required.
And as I said READ perm. is also required on Android 11+ for listing media files, that are not created by the app itself.

Read this guide:

This statement is also wrong, because the minSdkVersion is 7 with AI2 (Android 2.1, Eclair). On API < 19 (Android 4.4, KitKat) storage permissions are also required for the ASD.

Believe me, I've had quite a bit of experience with these "beloved" permissions for more than 10 years. :wink:

2 Likes

Thanks for your information.

Anyways most of the components requires min. Android level 5, so I believe most of the users won't face any issues using the extension to work with ASD.

No.

Then you shouldn't have provided these methods:

Not for non ASD actions, I am saying for ASD.

As I said, you must declare READ & WRITE permission in the Manifest (at least for API 7 - 18) also for ASD. So users must add a File component and enable the READ + WRITE permissions in the Designer.

2 Likes

Version 2 Updated

WHAT'S NEW

  1. Fixed file not downloading issue with some links.
  2. Renamed StopDownload to CancelDownload.
  3. Removed GetDownloadSpeed block due to internal issue.
  4. Added new method FileSize to get file size from file path.

image

1 Like

Hello, I am testing your extension and I have a problem that seems to be url dependent. I tested using your test app and also with simper example written by myself and the results are the same.

  1. Example that works: url = https://levocidiastarte.com filename: win.ico
  2. example that does not work: url = https:/levocidiastarte.com/tmp filename: win.ico
    this example does not work returning this error: Failed to download the file. Reason: placeholder

I uploaded the same files in both directories in the server, you may test with a normal browser, I did not put any read restrictions on those directories.
Do you know what means the error? And do you may explain me the different behaviour?
Thanks,
Massimo

Ok, I found the solution but in my opinion there is a problem. If my file is https://levocidiastarte.com/tmp/win.ico I have to input to ASD.DownloadFile url as https://levocidiastarte.com and as fileName tmp/win.ico and then it works. The problem is that DownloadFile saves the file in ASD/tmp (for ASD I mean the folder of the app ASD. I think that givin one more input (may be path?) could be better because the user can select the directory where download the file.

Hi,

As this extension is to download files in ASD, download file path is by default set to ASD. You can change the download location within the ASD in other folders but not outside the ASD.

If you want to save that file in other locations either you can copy the file from ASD to your preferred location after it is downloaded or use other download extension/component that allows you to set download path.