1
00:00:00,180 --> 00:00:07,170
So now in order to create a class in our project first I need to click on find Neal and then click on

2
00:00:07,170 --> 00:00:08,430
Java class.

3
00:00:08,430 --> 00:00:10,890
So now for the name of our class just type in here.

4
00:00:10,890 --> 00:00:15,810
SD card checker Okay.

5
00:00:16,170 --> 00:00:17,900
And then click on OK.

6
00:00:18,070 --> 00:00:20,640
So as you can see here this is our SD card check here.

7
00:00:20,690 --> 00:00:21,680
Our class.

8
00:00:21,690 --> 00:00:22,230
OK.

9
00:00:22,290 --> 00:00:23,230
So in this class.

10
00:00:23,280 --> 00:00:28,540
In this class I just want to actually to check whether we can actually write or read from the SD card.

11
00:00:28,620 --> 00:00:34,020
Ok now I'm going to actually paste in some lines of code here and then I'm going to explain to you what's

12
00:00:34,020 --> 00:00:34,940
going on here.

13
00:00:35,040 --> 00:00:39,140
So as you can see here these are the lines of code that they actually pasted here.

14
00:00:39,210 --> 00:00:39,730
OK.

15
00:00:39,860 --> 00:00:42,460
Or if I pasted this method here as you can see.

16
00:00:42,660 --> 00:00:47,670
So first of all let me explain to you that the access modifier of the Smurfit that they actually pasted

17
00:00:47,670 --> 00:00:49,560
here is public.

18
00:00:50,010 --> 00:00:52,400
And as you can see here this method is static.

19
00:00:52,400 --> 00:00:56,100
So we can actually refer to this method by using the name of this class.

20
00:00:56,200 --> 00:00:59,200
As the card check here that the name of the Smurfette.

21
00:00:59,200 --> 00:00:59,920
OK.

22
00:01:00,270 --> 00:01:04,340
And as you can see here the return type of this method is void.

23
00:01:04,500 --> 00:01:08,480
Check whether external storage available or not.

24
00:01:08,550 --> 00:01:11,020
OK so this is the name of this Mefford.

25
00:01:11,190 --> 00:01:11,810
OK.

26
00:01:12,090 --> 00:01:19,280
And this pivot actually accepts a context as you can see here the argument of this if it is context.

27
00:01:19,530 --> 00:01:24,610
And now inside this method I have two variables of type Boolean.

28
00:01:24,630 --> 00:01:28,680
The first one is is external storage available.

29
00:01:28,860 --> 00:01:33,800
And as you can see here I assigned the value of false to this variable OK.

30
00:01:34,020 --> 00:01:38,650
And the second one as you can see here is is external storage writable.

31
00:01:38,820 --> 00:01:44,040
And as you can see here the default value that I assigned to the symmetry about is false.

32
00:01:44,040 --> 00:01:50,370
So here as you can see I created another value but of type is strange and the name of this variable

33
00:01:50,370 --> 00:01:51,410
is state.

34
00:01:51,750 --> 00:01:58,430
And as you can see here I assigned this value to the Suadi environment that get external storage state.

35
00:01:58,470 --> 00:02:03,870
So it's going actually to check for that we can actually write or actually read from the SD card or

36
00:02:03,870 --> 00:02:04,420
not.

37
00:02:04,520 --> 00:02:04,980
OK.

38
00:02:05,100 --> 00:02:07,500
Environment that get external storage.

39
00:02:07,590 --> 00:02:14,340
So that value is going to be actually assigned to this state rowdier But and here I create it.

40
00:02:14,340 --> 00:02:22,410
And if else statement as you can see here if environment that media mounted that equals state.

41
00:02:22,680 --> 00:02:28,990
So this means that whether we can actually read and write the media on the SD card or not.

42
00:02:29,120 --> 00:02:29,700
OK.

43
00:02:29,740 --> 00:02:34,080
Environment that media mounted that equals state vision.

44
00:02:34,110 --> 00:02:40,140
What we can read and write the media also if this expression evaluates to true then we can actually

45
00:02:40,200 --> 00:02:46,130
read and write the media on the SD card and then as you can see here is external storage available.

46
00:02:46,170 --> 00:02:51,550
This value is variable assignment operator is external storage writable.

47
00:02:51,630 --> 00:02:53,700
This variable assignment operator.

48
00:02:53,700 --> 00:02:54,220
True.

49
00:02:54,420 --> 00:03:00,490
So I assign the value true to both of these variables to two both of these boolean variables.

50
00:03:00,690 --> 00:03:03,030
So we could actually write our code in this way.

51
00:03:03,060 --> 00:03:03,430
OK.

52
00:03:03,450 --> 00:03:05,220
Is external storage available.

53
00:03:05,220 --> 00:03:10,220
Assignment operator is external storage writable assignment operator.

54
00:03:10,220 --> 00:03:11,140
True.

55
00:03:11,940 --> 00:03:18,480
And here I created a toast in order to show the user that we can actually read and write from the SD

56
00:03:18,480 --> 00:03:18,830
card.

57
00:03:18,900 --> 00:03:25,230
As you can see here toast that make text first of all I actually put the context as you can see that

58
00:03:25,230 --> 00:03:29,220
we actually receive as an argument from the Smurfit context.

59
00:03:29,280 --> 00:03:33,870
The second one is the actually the message that I want to show to the user.

60
00:03:33,900 --> 00:03:39,740
Read and write and the first one is the length of the actually the message that you want to show to

61
00:03:39,740 --> 00:03:42,700
the use that the duration of the message that they want to show to the user.

62
00:03:42,990 --> 00:03:49,920
And I called this first show on these talks object and I have an ELSE IF statement.

63
00:03:50,010 --> 00:03:54,900
So if this expression evaluates to false then this expression is going to be evaluated.

64
00:03:54,900 --> 00:03:56,260
ELSE IF.

65
00:03:56,310 --> 00:04:01,630
ELSE IF environment that Medio mounted read only that equals state.

66
00:04:01,830 --> 00:04:05,710
So in this way we can all we can only read the media from the SD card.

67
00:04:05,730 --> 00:04:06,710
OK.

68
00:04:06,780 --> 00:04:13,710
If this expression evaluates to true then we can only treat the media and then assign a value to.

69
00:04:13,710 --> 00:04:16,450
This is this is external storage available.

70
00:04:16,460 --> 00:04:17,130
True.

71
00:04:17,640 --> 00:04:23,270
And I assigned the value files is external storage rightabout false as you can see here.

72
00:04:23,460 --> 00:04:26,780
And then I created a host object host that make text.

73
00:04:26,790 --> 00:04:33,520
First of all it is actually a scientist context for the first argument of this to make text Merfeld.

74
00:04:33,720 --> 00:04:39,540
And you can see here we receive this context as an argument of the Smurfette and then the second one

75
00:04:39,540 --> 00:04:44,760
is the message and the first one is the duration of the message that I want to show to the user.

76
00:04:44,850 --> 00:04:48,500
And I called this show my friend and this object tossed object.

77
00:04:48,930 --> 00:04:51,430
And we have an else statements here.

78
00:04:51,570 --> 00:04:58,500
So if both of these expressions evaluates to false then this expression and say This statement is going

79
00:04:58,500 --> 00:05:02,470
to be executed and neither read nor write.

80
00:05:02,490 --> 00:05:05,730
And the SD card is external storage available.

81
00:05:05,850 --> 00:05:11,370
Assignment operator is external storage writable assignment operator false.

82
00:05:11,370 --> 00:05:18,010
So I assigned the value false to both of these a boolean value else here as you can see here and that

83
00:05:18,010 --> 00:05:24,570
I created a toast object in order to show to the user that we can neither read nor write on the SD card.

84
00:05:24,640 --> 00:05:25,070
OK.

85
00:05:25,120 --> 00:05:27,130
So hopefully that makes sense.

86
00:05:27,610 --> 00:05:31,790
And now let's actually go back inside our our main activity the java file here.

87
00:05:31,840 --> 00:05:37,210
So inside our main activity file as you can see now you can actually call the Smurfit.

88
00:05:37,420 --> 00:05:44,680
So first of all because this is actually a static method we can actually we can actually choose to refer

89
00:05:44,920 --> 00:05:50,500
to the name of this class and then I put a dot operator and then I can actually refer to the name of

90
00:05:50,500 --> 00:05:51,220
the Smurfit.

91
00:05:51,370 --> 00:05:54,720
So here I am just typing an SD card Take care.

92
00:05:54,940 --> 00:06:01,830
So I referred to the name of this class that I created inside our project that SD card check hair that

93
00:06:03,660 --> 00:06:06,770
check whether external storage available or not.

94
00:06:07,020 --> 00:06:12,880
And now we can actually assign the value of value of type context.

95
00:06:12,920 --> 00:06:18,080
So context is this our class main activity that this.

96
00:06:18,210 --> 00:06:21,530
And now let's actually run our project and see what happens.

97
00:06:21,530 --> 00:06:24,780
So now as you can see it says lead and right.

98
00:06:24,880 --> 00:06:25,340
OK.

99
00:06:25,430 --> 00:06:28,990
So if we can actually read and write on the SD card.

100
00:06:29,090 --> 00:06:29,600
OK.

101
00:06:29,600 --> 00:06:31,690
So hopefully that makes sense.

102
00:06:31,730 --> 00:06:34,790
And now it's actually putting some more lines of code inside.

103
00:06:34,820 --> 00:06:36,420
Our main activity class.

104
00:06:36,440 --> 00:06:42,170
So now I'm going to actually pasting some lines of code here inside this main activity class and then

105
00:06:42,170 --> 00:06:44,010
I'm going to explain to you what's going on here.

106
00:06:44,150 --> 00:06:50,220
Here I'm going to actually declare some user interface components inside the main activity class.

107
00:06:50,270 --> 00:06:55,550
So as you can see here these are the lines of code that they actually pasted inside this main activity

108
00:06:55,550 --> 00:06:56,300
class.

109
00:06:56,300 --> 00:07:01,570
So first of all I actually created a button as you can see here between downloads folder.

110
00:07:01,670 --> 00:07:05,290
So as you can see I'm just declaring this button here.

111
00:07:05,300 --> 00:07:07,240
I'm not instantiating this project.

112
00:07:07,310 --> 00:07:08,800
Disputant OK.

113
00:07:08,980 --> 00:07:10,840
I'm just declaring this button.

114
00:07:11,210 --> 00:07:18,070
And here I actually declared and added a button between the music folder between documents folder between

115
00:07:18,080 --> 00:07:23,760
ringtones folder BATNA podcasts folders as you can see here we have these buttons here.

116
00:07:23,840 --> 00:07:25,090
OK.

117
00:07:25,190 --> 00:07:31,490
Download their music file their documents folder ringtones ringtones folder and so on.

118
00:07:31,880 --> 00:07:38,870
And as he has said he had Pythian about a test folder between the movies folder PTEN alarm's folder

119
00:07:39,200 --> 00:07:41,800
PTEN Pictures folder as you can see.

120
00:07:41,990 --> 00:07:44,460
And I have between pretty safe file.

121
00:07:44,660 --> 00:07:46,470
EDT value added text.

122
00:07:46,470 --> 00:07:50,700
So as you can see here I declared an edit text object here.

123
00:07:51,070 --> 00:07:58,670
And I have another button here between the retrieve info and I have a text view takes the value here

124
00:07:58,700 --> 00:08:05,450
I declared and image view and him on and here as you can see I declared and added a button between allow

125
00:08:05,450 --> 00:08:12,690
access pictures and as you can see here I declared and are linearly layouts here as you can see linearly

126
00:08:12,690 --> 00:08:17,330
out linearly and horizontal image through each image suture.

127
00:08:17,330 --> 00:08:22,700
So now let's actually instantiate these objects that they actually declared inside this main activity

128
00:08:22,700 --> 00:08:23,230
class.

129
00:08:23,390 --> 00:08:29,140
So inside this uncreate Smurfette after this line of code I'm going to instantiate those objects.

130
00:08:29,270 --> 00:08:35,060
So now here I went actually pasting some lines of code inside this uncreate method.

131
00:08:35,240 --> 00:08:37,700
And then I'm going to explain to you what's going on here.

132
00:08:37,700 --> 00:08:42,480
So as you can see here these are the lines of code that I actually pasted here inside this uncreate

133
00:08:42,520 --> 00:08:43,110
method.

134
00:08:43,190 --> 00:08:49,000
And as you can see here I am actually instantiating the objects that I actually declared inside the

135
00:08:49,070 --> 00:08:54,030
main activity class so that they can see BTA and download folder as you can see here.

136
00:08:54,260 --> 00:08:56,490
And it says between download directory.

137
00:08:56,630 --> 00:09:02,270
OK so because we want to actually create directories inside our For example downloads folder we can

138
00:09:02,270 --> 00:09:07,330
either call it download folder between downloads folder or download our directory.

139
00:09:07,340 --> 00:09:07,950
OK.

140
00:09:08,210 --> 00:09:09,190
It doesn't make any difference.

141
00:09:09,200 --> 00:09:15,980
But here I just wanted to show you that you can actually create a folder in site up for example and

142
00:09:15,980 --> 00:09:18,430
other directed in music for example for that.

143
00:09:18,440 --> 00:09:19,280
OK.

144
00:09:19,340 --> 00:09:25,850
So you can call it music directory or music folder or download directory or download folder and here

145
00:09:25,870 --> 00:09:32,510
as you can see I have Pythian music folder between music directory and here between documents folder

146
00:09:32,980 --> 00:09:39,440
and here as you can see between documents folder between our ringtones folder B.T. and process folder

147
00:09:39,590 --> 00:09:46,940
between movies folder and alarm's folder Pythian pictures folder pity and save file as you can see it

148
00:09:46,940 --> 00:09:55,280
is this the button is for this button as you can see we have a safe button here for actually saving

149
00:09:55,280 --> 00:10:01,590
some data to a file inside our documents folder as you can see here between savefile.

150
00:10:01,910 --> 00:10:07,390
And we have another button for retrieving those data inside another file in SD card.

151
00:10:07,520 --> 00:10:10,510
And this is the ID for that BT and retrieve the info.

152
00:10:10,760 --> 00:10:16,430
And if I go back and say this main activity that java file here we have this PTEN retrieve info as you

153
00:10:16,430 --> 00:10:23,270
can see here between retrieve the info and I have EDT value this is for getting text.

154
00:10:23,270 --> 00:10:26,590
This is for actually receiving Teske text from the user.

155
00:10:26,600 --> 00:10:32,770
And then put that text inside another file in SD card which claim I'm going to show you in a minute

156
00:10:33,020 --> 00:10:40,970
and you have TXI the value for actually getting those actually those inputs when the user actually put

157
00:10:40,970 --> 00:10:42,780
some text inside the editor.

158
00:10:42,830 --> 00:10:45,810
And then we build we want to actually retrieve those information.

159
00:10:45,830 --> 00:10:49,970
So if you want to put more information inside these TXI the value takes you.

160
00:10:50,270 --> 00:10:53,530
And we have EMG anemone as you can see here.

161
00:10:53,780 --> 00:10:59,090
We have BT and allow access pictures here we want to actually access the pictures inside the SD card

162
00:10:59,360 --> 00:11:03,130
and then don't look at those pictures inside these image switcher.

163
00:11:03,200 --> 00:11:10,640
So that's why I actually created these objects linearly out horizontally so linearly or horizontal is

164
00:11:10,640 --> 00:11:14,640
actually inside and they're actually horizontal scroll view.

165
00:11:14,660 --> 00:11:15,170
OK.

166
00:11:15,350 --> 00:11:20,430
And I have this image switcher for showing for showing the images then they use it or clicking on those

167
00:11:20,520 --> 00:11:23,110
images inside the city nearly what is on top.

168
00:11:23,280 --> 00:11:27,960
So now I'm going actually putting some more lines of code here and then I'm going explain to you what's

169
00:11:27,960 --> 00:11:28,890
going on here.

170
00:11:28,890 --> 00:11:33,310
So as you can see here these are the lines of code that I actually pasted here.

171
00:11:33,540 --> 00:11:39,030
And as you can see I am actually making these buttons that are inside these linearly and vertical these

172
00:11:39,030 --> 00:11:39,960
buttons for example.

173
00:11:39,970 --> 00:11:41,610
These Downloads folder.

174
00:11:41,730 --> 00:11:43,000
This immunity for the.

175
00:11:43,140 --> 00:11:44,170
And other buttons.

176
00:11:44,190 --> 00:11:46,710
A listener to the clicks of the user.

177
00:11:46,710 --> 00:11:47,190
OK.

178
00:11:47,250 --> 00:11:52,140
So for example between downloads for that certain click listener and here we need to actually passing

179
00:11:52,140 --> 00:11:53,280
the context.

180
00:11:53,320 --> 00:11:59,700
So main activity that this BTA and music for that certain click us and our main activity that is I have

181
00:11:59,700 --> 00:12:06,140
these PTEN documents folders that are set and click and listener main activity that this PTEN ringtones

182
00:12:06,140 --> 00:12:09,390
for their thoughts Stankovic listener main activity that this.

183
00:12:09,540 --> 00:12:16,860
And we have these bits and podcasts folder between movies folder PTEN alarms folder PTEN pictures folder

184
00:12:16,970 --> 00:12:20,150
BTA and save five PTEN retrieve info.

185
00:12:20,400 --> 00:12:24,010
And I enjoy that so then click listen and an activity that does this.

186
00:12:24,210 --> 00:12:29,460
But here we need to actually implement this article class and an interface for these buttons.

187
00:12:29,580 --> 00:12:38,520
So here after this act of compact activity here I just need to type in implements of view dot unclick

188
00:12:39,570 --> 00:12:43,110
listener so I have this view that actually exist in an interface.

189
00:12:43,140 --> 00:12:50,180
And here I just need to press Enter key on my keyboard and now I am actually implementing this Archilochus

190
00:12:50,180 --> 00:12:51,170
in our interface.

191
00:12:51,270 --> 00:12:57,540
And if I hover over this error area it says class main activity must either be declared abstract or

192
00:12:57,600 --> 00:13:04,650
implement abstract Smurfette unclick viewed as you can see we have our own view of you as an argument

193
00:13:04,680 --> 00:13:07,320
of this uncle Mefford in uncock listener.

194
00:13:07,500 --> 00:13:13,410
OK so Uncle Eagleson an uncle listener is actually an interface that we need to actually implement the

195
00:13:13,410 --> 00:13:18,720
abstract Mefford unclick you uncle if you insight this interface.

196
00:13:18,840 --> 00:13:26,250
So here after the Indian curly brace of the is uncreate Mefford here I can't just type in uncreate on

197
00:13:26,490 --> 00:13:27,250
click.

198
00:13:27,300 --> 00:13:35,100
I can just for example delete this method here and here again just insight is our main activity class.

199
00:13:35,100 --> 00:13:40,500
And after the Hadian curly brace of this uncreate method I can just throw eclectically here and then

200
00:13:40,720 --> 00:13:42,420
click can generate.

201
00:13:42,870 --> 00:13:49,320
And then here click can implement Moffats and here as you can see I have this android dot view to view

202
00:13:49,320 --> 00:13:52,040
that unclick listener interface as you can see here.

203
00:13:52,260 --> 00:13:55,860
And inside that interface here we need to actually implement this method.

204
00:13:55,890 --> 00:14:01,120
So here I just need to click on OK and now it's going to implement that Mefford for me.

205
00:14:01,170 --> 00:14:01,810
OK.

206
00:14:02,100 --> 00:14:07,860
And then here again just putting my own quotes that would be related to these buttons.

207
00:14:07,860 --> 00:14:16,350
So now as you may know in Android because we want to actually access the SD card and read or write for

208
00:14:16,350 --> 00:14:25,180
example some data on the SD card we need to actually first of all specify that we need to access the

209
00:14:25,200 --> 00:14:28,190
SD SD card in Android manifest.

210
00:14:28,230 --> 00:14:34,350
So after the Indian attack of this application tag as you can see here inside the manifest tank here

211
00:14:34,380 --> 00:14:37,860
I need to actually specify that or you want to access the SD card.

212
00:14:37,920 --> 00:14:45,330
So I just need to open a task here and then here I can just type in users permission and inside these

213
00:14:45,330 --> 00:14:45,990
double codes.

214
00:14:46,020 --> 00:14:48,000
I need to actually specify that what kind.

215
00:14:48,000 --> 00:14:50,230
What kind of features in Android.

216
00:14:50,240 --> 00:14:51,590
I meant to access.

217
00:14:51,630 --> 00:14:56,800
So here I want to actually read and write some data from the SD card.

218
00:14:56,850 --> 00:14:57,360
OK.

219
00:14:57,600 --> 00:15:05,030
So first for software for the first permission here I'm going to just type in read as you can see hear

220
00:15:05,540 --> 00:15:10,890
read and here is going to get you to show me some recommendations.

221
00:15:11,000 --> 00:15:15,440
And here I can choose read external storage as you can see here.

222
00:15:15,440 --> 00:15:22,250
Now here I can just close this tag here and here we need to actually use another repair mission.

223
00:15:22,280 --> 00:15:24,330
So here I just need to open this tag.

224
00:15:24,390 --> 00:15:26,590
Uses permission here.

225
00:15:26,600 --> 00:15:29,640
I want to actually specify that I want to write an SD card.

226
00:15:29,660 --> 00:15:30,160
OK.

227
00:15:30,230 --> 00:15:35,180
So here I can just type in right and here it's going to actually give me some options as you can see

228
00:15:35,180 --> 00:15:35,850
here.

229
00:15:35,960 --> 00:15:36,410
Right.

230
00:15:36,410 --> 00:15:37,090
Store right.

231
00:15:37,100 --> 00:15:38,490
External storage.

232
00:15:38,510 --> 00:15:39,710
So choose this option.

233
00:15:39,740 --> 00:15:42,010
And then a person entered key on your keyboard.

234
00:15:42,020 --> 00:15:47,860
So now I need to actually close the stack and now as you can see we can actually access the SD card

235
00:15:48,220 --> 00:15:54,200
but not yet here inside this main activity that a file we need to actually put in some lines of code

236
00:15:54,560 --> 00:16:02,180
regarding that we want to actually access the SD card and we need to actually get the user permission

237
00:16:02,570 --> 00:16:03,250
for that.

238
00:16:03,350 --> 00:16:03,810
OK.

239
00:16:03,950 --> 00:16:06,510
So here we actually are putting some more lines of code.

240
00:16:06,530 --> 00:16:10,280
And then I'm going to explain to you what's going on here.

241
00:16:10,340 --> 00:16:13,820
So here first of all we need a constant.

242
00:16:13,940 --> 00:16:18,480
For example our request called for actually using a permission in Android.

243
00:16:18,620 --> 00:16:23,390
So here I'm going to paste this constant here public as you can see this is the constants that they

244
00:16:23,390 --> 00:16:24,600
actually pasted here.

245
00:16:24,740 --> 00:16:26,300
Public static.

246
00:16:26,300 --> 00:16:28,060
So this constant is a static.

247
00:16:28,100 --> 00:16:28,640
OK.

248
00:16:28,850 --> 00:16:30,060
Final.

249
00:16:30,200 --> 00:16:32,040
And as you can see this is constant.

250
00:16:32,060 --> 00:16:34,450
It requires the code one to free forth.

251
00:16:34,580 --> 00:16:37,610
OK so this is my request code for using the permission.

252
00:16:37,610 --> 00:16:42,830
It doesn't make any difference what kind of numbers you use but I chose to use this one to free for

253
00:16:42,860 --> 00:16:43,260
number.

254
00:16:43,310 --> 00:16:44,070
OK.

255
00:16:44,330 --> 00:16:48,520
And now I'm going to paste in some of it and then I'm going to explain to you what's going on here.

256
00:16:48,530 --> 00:16:54,110
So as you can see here this is the method that they actually pasted inside these main activity class.

257
00:16:54,110 --> 00:16:54,640
OK.

258
00:16:54,860 --> 00:17:01,070
So the access modifier of this method is publish the return type of this method is boolean and the name

259
00:17:01,070 --> 00:17:04,370
of this method is is stored as permission granted.

260
00:17:04,790 --> 00:17:12,750
And here as you can see inside the body of the Smurfit I created an if statement so in Android in STK

261
00:17:12,770 --> 00:17:18,560
version at when a free and above we need to actually specify that what kinds of permission we want to

262
00:17:18,560 --> 00:17:25,020
use in Android and we need to actually get to get the permission of the user for using those features.

263
00:17:25,070 --> 00:17:33,040
OK but before the SDK to be freed up we just needed to specify that that those permissions in Android

264
00:17:33,050 --> 00:17:40,060
manifest but in SDK to any free and pop we need to specify it was permissions in in our Java codes too.

265
00:17:40,100 --> 00:17:47,120
So that's why I created an if statement build that version is the it is greater than or equal to number

266
00:17:47,120 --> 00:17:47,890
23.

267
00:17:47,900 --> 00:17:55,430
Here I am specifying that if the STK version is 20 free or greater than 23 and here I created another

268
00:17:55,440 --> 00:17:56,900
if statement if.

269
00:17:56,900 --> 00:17:58,010
Check self permission.

270
00:17:58,010 --> 00:18:00,730
So this is another method builtin in Android.

271
00:18:00,770 --> 00:18:07,940
OK if takes self permission and that manifested permission right external storage.

272
00:18:08,020 --> 00:18:08,690
OK.

273
00:18:08,780 --> 00:18:11,820
Is equal to package manager that permission granted.

274
00:18:11,990 --> 00:18:19,070
Ok so because you want to actually write and or read from the SD card if you actually have the permission

275
00:18:19,340 --> 00:18:24,530
to write an external storage if you have the permission to read from the external external storage too.

276
00:18:24,640 --> 00:18:25,190
OK.

277
00:18:25,550 --> 00:18:31,460
So if checks have permission and troit that manifested permission write X then storage is equal to package

278
00:18:31,460 --> 00:18:34,460
manager package manager that permission granted.

279
00:18:34,550 --> 00:18:39,770
So if we have the permission to access the the external storage.

280
00:18:39,800 --> 00:18:41,880
OK here I created a plug.

281
00:18:41,990 --> 00:18:43,810
OK LUGG permission is granted.

282
00:18:43,880 --> 00:18:44,790
Return true.

283
00:18:44,990 --> 00:18:51,770
So if it is going to actually return TRUE else else as you can see I have an else statement here else

284
00:18:51,780 --> 00:18:53,380
permission is revoked.

285
00:18:53,450 --> 00:18:59,230
OK so we don't have the permission to actually access the external storage.

286
00:18:59,240 --> 00:19:05,270
So here I just referred to this activity computer class we have this activity that the class as you

287
00:19:05,270 --> 00:19:08,320
can see that request permissions.

288
00:19:08,330 --> 00:19:11,660
So here we want to actually request the permissions in Android.

289
00:19:11,730 --> 00:19:13,850
So this this is the context.

290
00:19:13,850 --> 00:19:17,630
And here I have an object new string.

291
00:19:17,660 --> 00:19:21,670
So if you have an object of actually an array of string objects.

292
00:19:21,680 --> 00:19:22,160
OK.

293
00:19:22,190 --> 00:19:28,940
And inside these are actually curly braces we need to specify what kind of actually the what kind of

294
00:19:28,940 --> 00:19:31,120
permissions we want to use.

295
00:19:31,190 --> 00:19:33,450
Ok manifest that permission right.

296
00:19:33,470 --> 00:19:34,970
External storage.

297
00:19:35,420 --> 00:19:38,870
And here we need to actually use or request code.

298
00:19:38,960 --> 00:19:44,770
So here use this number one as you can see here and then I return false.

299
00:19:44,780 --> 00:19:51,570
So this method is going to actually return false if we don't have any permission to access this.

300
00:19:51,650 --> 00:19:53,990
For example Raghda external storage.

301
00:19:54,020 --> 00:19:54,480
OK.

302
00:19:54,530 --> 00:19:57,670
And here we have another statement.

303
00:19:57,680 --> 00:20:02,590
So as you can see here if the STK version is actually less than number 23.

304
00:20:02,750 --> 00:20:10,390
OK permission is granted permission is automatically granted on STK less than number 23 upon installation.

305
00:20:10,440 --> 00:20:11,160
OK.

306
00:20:11,160 --> 00:20:12,770
Permission is granted return true.

307
00:20:12,780 --> 00:20:14,610
So this it is going I should return true.

308
00:20:14,700 --> 00:20:21,830
OK so now we need to actually override another builtin method in Android.

309
00:20:21,960 --> 00:20:25,200
And and here I'm going to pasting that method here.

310
00:20:25,200 --> 00:20:30,870
So as you can see here this is the builtin method that I actually pasted here on request permission

311
00:20:30,870 --> 00:20:31,650
result.

312
00:20:31,660 --> 00:20:37,530
So whenever you use that for example gives me an operation to use some features in Android D-SLR if

313
00:20:37,550 --> 00:20:38,480
it is going to be called.

314
00:20:38,530 --> 00:20:42,810
OK so this least fit as you can see our accepts some arguments.

315
00:20:42,900 --> 00:20:45,460
The first argument is request code.

316
00:20:45,510 --> 00:20:53,040
The second argument is permissions as you can see here we have an array of permissions and we have Grantley's

317
00:20:53,190 --> 00:20:56,360
results which is of type integer arii.

318
00:20:56,400 --> 00:20:56,960
OK.

319
00:20:57,240 --> 00:21:03,270
And here it called the superclass version of this method superdad and request the permission result

320
00:21:03,540 --> 00:21:06,400
request code permissions Granth results.

321
00:21:06,630 --> 00:21:12,190
And here I created an if statement if Granth results.

322
00:21:12,630 --> 00:21:13,370
Sub-Zero.

323
00:21:13,380 --> 00:21:13,770
OK.

324
00:21:13,830 --> 00:21:19,830
So if for example if the permission in index zero of this Granth results.

325
00:21:19,920 --> 00:21:24,990
So if you have these permissions for this permission write extension storage is going to be at index

326
00:21:24,990 --> 00:21:31,990
0 of this Granth results rate is equal to package manager package manager that permission granted.

327
00:21:32,070 --> 00:21:40,170
So if we can X access for example that the external storage and right on the card if that permission

328
00:21:40,170 --> 00:21:41,510
is granted to us.

329
00:21:41,790 --> 00:21:47,510
OK so is it this expression is going to be true if the permission is granted to us.

330
00:21:47,680 --> 00:21:52,950
Now it's created a large LUGG permission plus permissions.

331
00:21:52,950 --> 00:21:55,670
Sub-Zero was Granth results.

332
00:21:55,680 --> 00:21:56,200
OK.

333
00:21:56,280 --> 00:22:04,080
Sub-Zero so Granth results for example their results for actually giving us permission to use that feature

334
00:22:04,080 --> 00:22:04,650
in Android.

335
00:22:04,650 --> 00:22:07,400
OK so we need to override this method here.

336
00:22:07,500 --> 00:22:08,010
OK.

337
00:22:08,340 --> 00:22:10,610
And now inside is uncreate Smurfette.

338
00:22:10,620 --> 00:22:17,880
I'm going to actually writing MF it actually referred to this is stored is stored is permission granted

339
00:22:18,060 --> 00:22:24,900
here Ivan actually referred to dismember inside this uncreate Smurfit in order to show the user a message

340
00:22:25,110 --> 00:22:28,140
whether we can actually access the external storage or not.

341
00:22:28,150 --> 00:22:29,570
OK so here I can just type in.

342
00:22:29,570 --> 00:22:33,950
It is stored as storage permission granted semicolon.

343
00:22:34,110 --> 00:22:38,210
OK and now let's actually run our project and see what happens.

344
00:22:38,250 --> 00:22:45,600
So now as you can see here our application is actually running on this emulator and that device actually

345
00:22:45,600 --> 00:22:47,380
the application automatically.

346
00:22:47,380 --> 00:22:48,980
And now he's showing me this message.

347
00:22:49,110 --> 00:22:55,540
Allow app for free to access photos media and files on your device.

348
00:22:55,560 --> 00:23:02,940
So if I click on deny or I'm not allowed to access the SD card OK and if I click on allow I am allowed

349
00:23:03,180 --> 00:23:07,950
to access the SD card and write some data or it's Sunday to or from the SD card.

350
00:23:07,980 --> 00:23:08,570
OK.

351
00:23:08,760 --> 00:23:10,430
So this actually can deny.

352
00:23:10,700 --> 00:23:17,430
And now I don't have the permission to access any directory or files or photos in SD card.

353
00:23:17,640 --> 00:23:24,460
So let me actually click on this batch button here and now let me actually go to the background apps.

354
00:23:24,480 --> 00:23:26,650
So here this app is actually in the background.

355
00:23:26,670 --> 00:23:32,700
But this app this app is actually destroyed because I clicked I clicked on this back button in the undestroyed

356
00:23:32,700 --> 00:23:33,870
my father is actually current.

357
00:23:33,930 --> 00:23:39,740
So if I actually click on this app here again at the uncreate my fate is going to be called again.

358
00:23:39,870 --> 00:23:47,970
So now as you can see again it's showing us this message allow app 83 to access photos media and files

359
00:23:48,270 --> 00:23:49,590
and files on your device.

360
00:23:49,590 --> 00:23:51,450
So here we have another option.

361
00:23:51,450 --> 00:23:52,700
Never asked again.

362
00:23:52,740 --> 00:23:57,160
So if I check this option and then click on D-NY it's not going to show me this message again.

363
00:23:57,240 --> 00:24:03,440
And the user has to actually allow the permissions that this app needs in the settings app.

364
00:24:03,620 --> 00:24:05,010
In the Android device.

365
00:24:05,010 --> 00:24:05,550
OK.

366
00:24:05,760 --> 00:24:11,550
So if we actually check this option and now at this time I want to allow the user to access.

367
00:24:11,700 --> 00:24:15,340
For example allow the app to access the files in the SD card.

368
00:24:15,360 --> 00:24:15,780
OK.

369
00:24:15,870 --> 00:24:17,640
So let me actually click on now.

370
00:24:18,050 --> 00:24:21,910
And now I am allowed to access the files in SD card.

371
00:24:22,020 --> 00:24:31,020
OK so let me actually click on the spot button again and here again we actually open this up here and

372
00:24:31,020 --> 00:24:33,630
now it's not going to show me that message again.

373
00:24:33,840 --> 00:24:40,410
OK so here I am allowed to access the files in SD card and that's because of these methods that they

374
00:24:40,410 --> 00:24:43,170
actually put here in site of this class.

375
00:24:43,170 --> 00:24:43,730
OK.

376
00:24:44,010 --> 00:24:50,640
So here instead of just using this number of one I could just use these are requests that constant that

377
00:24:50,640 --> 00:24:51,710
they actually put here.

378
00:24:51,810 --> 00:24:52,670
OK.

379
00:24:52,740 --> 00:24:58,380
I created this constant here in order to show you that if you want to actually use other permissions

380
00:24:58,950 --> 00:25:03,780
other than this right external storage in Android here if you want to use other commissions you need

381
00:25:03,780 --> 00:25:07,200
to actually to use other request codes for those permissions.

382
00:25:07,200 --> 00:25:07,660
OK.

383
00:25:07,830 --> 00:25:10,730
So I created this up request court for showing you that.

384
00:25:10,770 --> 00:25:14,310
But here I just preferred to use this number one here.

385
00:25:14,400 --> 00:25:15,110
OK.

386
00:25:15,150 --> 00:25:16,710
So hopefully that makes sense.

