Andoid KIVY python permissions READ Issue. PLEASE HELP

187 views
Skip to first unread message

Jason Watkins

unread,
Aug 30, 2023, 5:30:10 AM8/30/23
to Kivy users support
Hi, I've having an issue reading from external storage after I manually modify the text file I've save there. I'm writing to 'Dowload' directory. I'm able to read the file back from this location before it is modified say from connecting my phone to my linux laptop and making the changes. It appears to be a permission issue.

Thanks


My python program has the following set 
from android.permissions import request_permissions, Permission   ####needed for Android cammera permission
request_permissions([Permission.CAMERA,Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE])


and my buildozer.spec file has
android.permissions = READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE,MANAGE_EXTERNAL_STORAGE,CAMERA


Robert

unread,
Aug 30, 2023, 12:28:06 PM8/30/23
to Kivy users support
On modern Android devices files in Download are owned by the app that downloaded (wrote) them.
There may be a way round this, but I don't know.

Jason Watkins

unread,
Aug 30, 2023, 3:42:37 PM8/30/23
to Kivy users support
Hi, Does anyone know of a solution to this issue?

Many Thanks

Robert

unread,
Aug 30, 2023, 7:18:06 PM8/30/23
to Kivy users support
There really is no issue in the sense that anything in the OS or the tools are broken.
The issue is the programmer is trying to do desktop style programming on a mobile device.

Turn your head around.

The app needs to get the file rather than be given the file by an external source. Which if you think about it being given the file is a security risk.

Jason Watkins

unread,
Aug 31, 2023, 3:44:23 AM8/31/23
to Kivy users support
Robert, so how do other programs like Adobe Acrobat are able to read/load user's pdf files?

Thanks

Robert

unread,
Aug 31, 2023, 12:52:12 PM8/31/23
to Kivy users support
You have to ask them.

Holger B

unread,
Sep 2, 2023, 10:25:55 AM9/2/23
to Kivy users support
I do not know whether this helps here, but to append to  a log.txt log file and then copy it to the shared "Documents" folder from kivy I previously used SharedStorage (https://github.com/Android-for-Python/androidstorage4kivy) :
### first step: write to app-private storage
if kivy.utils.platform == 'android':
   sdpath = App.get_running_app().user_data_dir
   fname = os.path.join(sdpath, logfilename)
   self.log = open(fname, "a")
   self.log.write(my_text)
   self.log.close()
### second step: copying the log file from the app-private storage to shared storage
if kivy.utils.platform == 'android':
    from androidstorage4kivy import SharedStorage
    ss = SharedStorage()
    share0 = ss.copy_to_shared(os.path.join(App.get_running_app().user_data_dir, 'log.txt'))
    print(f"python: copy result {share0}", file=sys.stderr)
... fwiw / there might be more elegant ways
Best, Holger
Reply all
Reply to author
Forward
0 new messages