Ploy_V
September 9, 2022, 8:46am
1
Trying to make app read text file after pick choice, permission allow, directory checked, file found but can't open file
Android 7.0
Anke
September 9, 2022, 9:11am
2
Access to non-media files on Android 11+
On Android 11+, non-media files (like txt, pdf, csv, ...) can be accessed
if and only if
the text files are in the → ASD or in the → Private dir (i.e. were saved there), or
the text files are in one of the Shared folders /Documents or /Download and
these files were created by the app itself, or
SAF is used, or
MANAGE_EXTERNAL_STORAGE* permission is requested and granted.
*` This is not really an option, because an app that requests this permi…
From an Android point of view there are an → Internal Storage and an → External Storage .
1. Internal Storage
The Internal Storage can only be accessed with a rooted device.
1.1 The app package is saved in
/data/data/<packageName>/
In order to be able to debug your app, AI2 saves the assets for → Companion on devices with
Android ≥ 10 (API ≥ 29):
/storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/assets/
Android < 10 :
/storage/emulated/0/Android/data/edu.mit…
Always show your blocks and name the Android version, see here:
Before you ask a question / open a new topic
please take care of the following points:
The forum was previously searched for similar topics / issues.
Give a precise (detailed) description of
the issue / bug,
the goal.
Show the (relevant) blocks (images, screenshots of blocks in high quality).
Debug your blocks (connect to Companion and right mouse click: → Do it).
Name the Android / iOS version running on your (test) device.
Do not open multiple threads on the same topic.
If you haven't al…
Ploy_V
September 9, 2022, 10:44am
3
Sorry for missing info Code and Android version added
Anke
September 9, 2022, 10:53am
4
Read my posts !
If a non-media file is NOT created by the app itself, it cannot be read / accessed from one of the Shared
folders /Download
or /Documents
or any other arbitrary folder of the external storage (outside the ASD) on Android 11+. You must use SAF .
Where does the text file come from?
1 Like
Ploy_V
September 9, 2022, 11:59am
5
I do read first 2 post before create this topic.
This text file is download from my PC and put into /Download
Anke
September 9, 2022, 1:01pm
6
Then ...
Anke:
You must use SAF .
on Android 11+ to access it.
But even with SAF you cannot access files in the Shared folder /Download
, but in /Documents
or any another folder - exept the root directory of the external storage.
Suggestion :
Put the text file in assets, then copy it to /Download
and read it from there. Or upload it to Google Drive, then download it to the ASD and read it from there.