Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not able to acess files unless connected to adb once #2907

Closed
0Beshoy opened this issue Oct 28, 2023 · 2 comments
Closed

not able to acess files unless connected to adb once #2907

0Beshoy opened this issue Oct 28, 2023 · 2 comments

Comments

@0Beshoy
Copy link

0Beshoy commented Oct 28, 2023

I have a kivy app that creates a directory called DownTunes in Music Public Directory and downloads music in it the app works fine on my phone i tried it on another phone it opened correctly but it didnt create the directory DownTunes nor downloaded anything so i connect this phone to the laptop and open adb to see the erro,r the app worked fine after i connected to adb, i tried reinstalling disconnecting and everything and it still worked, i tried it on 2 other phones and it didnt work , it appears to me that the app is unable to acess phone storage unless connected to adb once , anyone knows why ? here is my code for acessing storage ( i tried to create the directory manually and then download it didnt work)

if platform == "android":
from android.permissions import request_permissions, Permission

request_permissions(
    [
        Permission.INTERNET,
        Permission.WRITE_EXTERNAL_STORAGE,
        Permission.READ_EXTERNAL_STORAGE,
        Permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS,
    ]
)

Environment = autoclass("android.os.Environment")
path = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_MUSIC
).getAbsolutePath()
File = autoclass("java.io.File")
down_tunes_directory = File(path, "DownTunes")

@mainthread
def create_directory(dt):
if not down_tunes_directory.exists():
down_tunes_directory.mkdirs()

@RobertFlatt
Copy link
Contributor

Device android versions are probably significant in this case.
I don't know why connecting with adb would make any difference.

The approach used in the code above only works on Android <10
Read about Android storage https://github.com/Android-for-Python/Android-for-Python-Users#android-storage

Support issue.

@0Beshoy
Copy link
Author

0Beshoy commented Oct 30, 2023

@RobertFlatt Yes but my phone is android 13 and somehow it works, am now trying to request MANAGE_EXTERNAL_STORAGE, and making requestlegacyexternalstorage to true and will see if it works

@0Beshoy 0Beshoy closed this as completed Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants