Read and Write external storage permission isn't working

后端 未结 5 1642
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-08 00:58

In my app i want to get user permission to read and write data on external storage, i have put permission tag in my manifest as below. But when installing app or running and whe

5条回答
  •  Happy的楠姐
    2021-02-08 01:42

    Clean the damn project, rebuild and run if it still does not work....

    Add this code in onCreate method in your activity. Delete the app, clean the project, build and run. Also do not forget to add the permission you want in your manifest. (For a lower API level the code is unnecessary but from 23 and up you also need this code)

    private fun requestPermission() {
    
        val permissions = arrayOf(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.WRITE_EXTERNAL_STORAGE)
        this.requestPermissions(permissions, 5)
    }
    

提交回复
热议问题