Skip to content

Commit

Permalink
fix _get_sdcard_dir for Android API < 24 (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
DexerBR authored Nov 1, 2023
1 parent d8a2b3d commit 9d96fe5
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions plyer/platforms/android/storagepath.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
'''

from plyer.facades import StoragePath
from plyer.platforms.android import SDK_INT
from jnius import autoclass, cast
from android import mActivity

Expand Down Expand Up @@ -31,14 +32,20 @@ def _get_sdcard_dir(self):
)

if storage_manager is not None:
storage_volumes = storage_manager.getStorageVolumes()
for storage_volume in storage_volumes:
if storage_volume.isRemovable():
try:
directory = storage_volume.getDirectory()
except AttributeError:
directory = storage_volume.getPathFile()
path = directory.getAbsolutePath()
if SDK_INT >= 24:
storage_volumes = storage_manager.getStorageVolumes()
for storage_volume in storage_volumes:
if storage_volume.isRemovable():
try:
directory = storage_volume.getDirectory()
except AttributeError:
directory = storage_volume.getPathFile()
path = directory.getAbsolutePath()
else:
storage_volumes = storage_manager.getVolumeList()
for storage_volume in storage_volumes:
if storage_volume.isRemovable():
path = storage_volume.getPath()

return path

Expand Down

0 comments on commit 9d96fe5

Please sign in to comment.