File Questions Again

Sorry for the Post. I know this has been discussed thousands of times, but there seems to be a lot of conflicting information.

Being able to access files is an extremely important topic. Google’s latest changes with Android 11 seems to have thrown a monkey wrench into the process.

I have an Android 11 device. I have an app written in the current Kodular that writes, shares, and deletes files and accesses SQLite databases from the Application Specific Directory (ASD) at:
/storage/emulated/0/Android/data//files.

The user needs access to these files. It used to be nice because this directory used to have global privileges and anyone could get to it (Including file managers, and FTP server programs).

With the extension EFile I am able to write a file to this directory. With the built-in Storage-File blocks I’m not able to write to or share files from this directory. It says the file does not exist. I found a file manager, after a lot of searching, that shows me the file is there. EFile does not have a delete method.

What is the correct way to access this directory?

How are things going to change with the new version of Kodular and Google’s ridiculous file system proclamations?

Thanks,
Barry.

From the OP:

I’ve been looking around in this form. My device is Android 11.

I saw a post saying, that it seemed to work on somebody’s Google 2xl, so must work. I have three Android 11 devices and they all seem to handle the new storage rules a little differently. I have found things that work on one, but not another.

For my app I need to be able read/write to my own ASD in external storage. I don’t need access to the ASDs of other apps on the phone.

I have a file manager that allows me access to all app’s ASDs – at least I can see what’s going on.

I’ve tried many of the suggestions on this form – of using /sdcard instead of /storage/emulated/0, prepending file://,…

None of these seem to work. I use the extension “de.bodymindpower.GetASD.aix” EFile to get the ASD directory. It works great. I wish it had methods for FileExists and FileDelete – I’d be all set. I can’t seem to access anything in my ASD using the Kodular built-in Storage-File methods.

I wonder how things are going to work for apps that may be running on Android < 11 versus Android 11 and greater once the Kodular update is released?

Barry.

did you try a search in the community for ASD?

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.

use a file extension… or just wait a few days intil the SDK30 release is out… the file component will get some new methods…

Taifun

1 Like

Thanks. Here are some blocks for an example:

This code above works as expected. Notice I use the extension EFile to get the ASD directory, then write a bunch of lines to a text file in that directory.

image

This code above does not work. Notice I use the same ASD filename and use the built-in Storage-File blocks to test if the file exists and/or delete the file. The file name and location showed in the Alert is correct. It says the file does not exist although using my file manager I can see the file is there. I’ve done things to make sure my file manager is not cacheing things to only make it look like the file is there. I’ve also modified the file name to use /sdcard instead of /storage/emulated/0 and in both cases played around with prepending file:// to FName. It always ends up saying the file does not exist.

Barry.

are you saying, the Exists method does not work?
did you try to use a relative path?
i.e.try to remove /storage/emulated/0 from the path…
but as already said

Taifun

Yes. The Exists and Delete methods in the Kodular built-in Storage-File blocks do not work for my ASD path starting with /storage/emulated/0. I tried replacing the path with just /sdcard. That also did not work. I have not tried removing /storage/emulated/0 from the path altogether.

I downloaded your TaifunFile extension. I’m using the Exists and Delete methods from your extension with my ASD path. It works perfectly. I hope it continues to work with the SDK30 version of Kodular.

Thanks,
Barry.

1 Like