4

I am looking for a solution regarding loading images from internal storage file manager via my kivy application.

for testing,i need to select the image from internal storage and then convert it into gray scale image by using opencv.

I have tried filechooserlistview,but however i could not access my internal storage.

I have also added below mentioned line in my buildozer.spec file. android.permissions = READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE

i'm searching for this solution for the last two days but i didn't get any proper result yet.

Please share the code if anything you have. Thanks in advance

Velmoorthi
  • 160
  • 2
  • 11
  • check this one https://stackoverflow.com/questions/43452697/browse-an-image-file-and-display-it-in-a-kivy-window – Chitkaran Singh Nov 23 '19 at 10:19
  • Thank you so much @ChitkaranSingh for your fast response.Is it possible to create a folder in file manager via our android application? where i have to store my converted image.If you have anything related to this please share with me. – Velmoorthi Nov 23 '19 at 12:46

2 Answers2

3

In newer Android systems, the buildozer permission request for accessing the storage is not working with kivy.
To acquire these permissions you have to ask for them in your app by:

from android.permissions import request_permissions, Permission
request_permissions([Permission.WRITE_EXTERNAL_STORAGE,
                     Permission.READ_EXTERNAL_STORAGE])

... and the user will be asked to your App to access the storage.
The android library is included in the buildozer builds, so that request is all you have to do...

To get the internal storage path:

from android.storage import primary_external_storage_path
SD_CARD = primary_external_storage_path()

Note that this is the virtual (internal) SD card of the system.

noEmbryo
  • 2,176
  • 2
  • 10
  • 15
  • Thank you for the clarification..After using your logic it works on my friend mobile which has external storage. But I don't have an external storage. I have only my default internal storage. When I was clicking filechooserlist it shows me only blank.. Is there any possible to select file from my internal storage? – Velmoorthi Nov 23 '19 at 14:17
1

Try with path /storage/emulated/0/

As an example, mention it in your .kv file

#:import platform kivy.utils.platform
FileChooserListView:
    rootpath: '/storage/emulated/0/' if platform == 'android' else '/'
Niteesh
  • 46
  • 2