From the course: Android Development Essential Training: Manage Data with Kotlin

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Request external storage permissions

Request external storage permissions

From the course: Android Development Essential Training: Manage Data with Kotlin

Start my 1-month free trial

Request external storage permissions

- [Instructor] Starting in Android 6, dangerous permissions have to be requested at run time. If you declare a dangerous permission in your manifest, and that application is installed on an older version of Android, it'll be granted during installation. But for all more recent versions, you have to add the code yourself. I want to be able to write to external storage. So, I'm going to add a couple of uses permission elements to my Android manifest. The first one will be for READ_EXTERNAL_STORAGE, and that's a normal permission. It doesn't need special treatment, but here's the dangerous permission, WRITE_EXTERNAL_STORAGE. So, I've declared the permissions, but now I have to add the code. In the previous video, I set up my splash fragment as the place to do that. I'll add the code here in the onCreateView function. I'll add a conditional block, and I'll use this expression: if ContextCompact.checkSelfPermission and I'll pass in two arguments. First the context, which will be with…

Contents