Android app can't read external storage files

后端 未结 5 556
遇见更好的自我
遇见更好的自我 2020-12-19 18:52

I\'m creating an app for a private use only... it\'s not so important then, respect your time :P

What I want to make is an app that reads from a database and plays s

5条回答
  •  一整个雨季
    2020-12-19 19:36

    You also have to have the permission READ_EXTERNAL_STORAGE; Either write or read is not enough when it comes to external storage, as you have to use both

    
    

    You can also read more about external data writing in the declaration

    The reason you cannot read is because you didn't add that permission. A good rule is if you only need to read, only use read permission. But if you need to write you need the write and the read permission

    EDIT:

    When loading the directory, try this:

    file.setReadable(true);
    file.setWritable(true);
    

    Note: the value 'file' here is for the directory, not each separate file(all though that works fine too)

    From the declaration:

    This permission is enforced starting in API level 19. Before API level 19, this permission is not enforced and all apps still have access to read from external storage.

    If I am correct that means the permission has to be there from API 19 and up, but not before API 19

提交回复
热议问题