[Android ≤ 10] How do I read from a file in Internal Storage instead of SD Card with file component?

Hi!

I am using the image component, to read a punedata.txt file stored in my raw Internal Storage.

When I use the blocks (1) block with the path /punedata.txt, it says ‘Error 2101 : the file /punedata.txt could not be found’. I also tried adding /storage/emulated/0/punedata.txt as the path, but the same error occurs.

Here's what the file's path (from my device's file manager) looks like


What should I do in order to access a .txt file stored in direct Internal Storage? Your help would be very appreciated!

Thanks!

join file://with it

1 Like

blocks (2)

@Rahan_Sarang Still the same error - ‘Error 2101 : the file file:///storage/emulated/0/punedata.txt could not be found’

What should I do?

@Rahan_Sarang Also, do you happen to know why does the file component have SD-Card set as default path?

Dont know why try to ask storage permission

1 Like

You can no longer access the root dir of the external storage on Android 11, at least not as far as non-media files are concerned.

2 Likes

this is the internal (emulated) sdcard…
you might want to read from shared storage like /Download or from the ASD - application specific directory… see also the overview

Taifun

1 Like

Update -

I solved my problem by enabling Legacy Mode, then using these blocks -

image

This works like a treat. Thanks everyone!


BTW here’s how I got the idea for enabling Legacy Mode : File - Kodular Docs

Which Android version did you test it on? Apparently not with an Android 11 device.

As I said before, the root directory of the external storage is no longer accessible under Android 11 as far as non-media files are to be accessed (even not with SAF). This would require MANAGE_EXTERNAL_STORAGE Manifest.permission  |  Android Developers. (This special permission will Google most likely not grant for your app).

So this is not a solution.

1 Like

Hi @bodymindpower,

Yes, I did not test it on Android 11, but on 10 (as my device doesn’t have 11). Since it was a personal app, it works for me.

I still have edited the topic’s title to [Android <10]

Thanks!

It should read: Android ≤ 10, because Kodular has decided to continue to declare android: requestLegacyExternalStorage = "true" in the Manifest (therefore it still works under Android 10).

See also here:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.