Okay now let's actually open this Android device monitor here as you can see we have this little Android
image here.
Click on it and it's going to open the Android device monitor for us.
So as you can see here inside this Android device monitor application we have some taps here.
So just a selectees file explorer tab as you can see here.
Now let me actually make this area wider.
And now as you can see if you have some files here.
OK.
We want to actually access these toilets about application.
So as you can see here let me try to open it again.
Now as you can see money still quit unexpectedly so this is a bug in our Android device Monita.
So here I just need to reopen this application again here and now as you can see here we have these
storage folder here as you can see here.
I just need to open these stores folder.
We have an emulator folder here as you can see.
Open it and here we have a folder and the name of this folder is zero.
And as you can see here we have these directories inside this folder.
So if you don't have these directories in your Android device monitor as I have here as you can see
alarm's directory and Android directory directory documents directory download directory movies directory
you can actually create another directory of the custom name as the name of these directories that I
have here.
OK.
So here in order to create another directory here you just need to select this a zero folder here.
As you can see and then click on this plus button here and now you can actually create an order for
there.
Here.
OK.
So be sure to actually create a folder with the name as the name of these directories that I have here.
For example movies directory with a capital M music directory with a capital M notification it's directory
pictures directory Portchester directory and the victims directory or alarm's directory and then you
can actually click on.
OK.
So if you don't have these directories that I have here you can create these directories here.
And as you can see here for example inside this download electively I created an order directed here
by using the application and the name of this directory is these are download for example or some other
name or inside these movies directly.
I have another directory migrate to movies.
OK I have another folder.
So and then I can actually put some other files here and as you can see here at the top here.
We have another option.
For example this option here says pull a file from the device.
So here we can actually pull another file from this device and put it on the desktop.
So if I click on this button here now I can actually for example choose other options.
OK.
And then and then I can actually put put that there.
And as you can see here because I selected these are my great movies folder here.
It's going to actually take this file here.
OK.
And then create a copy from this file.
And then for example here I need to actually specify a location for saving that file in my computer.
And then if I click on the stop here and then click on for example open.
Now it's going to actually put this folder inside in my on my desktop.
So as you can see here this is my desktop and I have this directory migrates movies folder.
OK.
So here I can actually access this folder.
And here I've actually pulled this folder from my device and here as you can see inside this hour a
device monitor.
I didn't do that by using this button here.
And here if I click on this button here push a file onto the device I can actually write another file
and put it inside this Android device monitor.
So here for example instead I have a picture is directed here.
And here I have my great pictures and here for example I have this image here.
So here in order I have in order to actually delete a file from your Android device manager you just
need to select it and then click on this minus button here as you can see delete the selection and then
it actually deleted this image for me.
And if we actually want to put another image into these pictures they're here I just need to select
the spot in here and then in it on my desktop I have another image Tiger P in G.
If I select it and then click on open here now it's going to actually put that image here inside my
pictures folder.
So here I have this image.
OK.
So hopefully that makes sense.
And now let's actually go back to our Android studio so here after the end in curly brace of these uncreate
method I'm going actually pasting method and then I'm going to explain to you what's going on here.
So as you can see here I have these Smurfette here.
OK.
Public file.
So as you can see the Axis modifier of this it is public and the return type of this method is file.
OK.
So this is going to actually return an object of type file.
OK.
And then the name of this method is return storage directory for folder name.
OK.
And this Meffert actually accepts two arguments.
Strange directory name.
OK.
And strength.
Name of folder.
OK so what's what's this.
It is going to do.
As you can see here inside our Android monitor Android device monitor we have some directories here
some default directories alarms DC and documents or downloads.
And inside is actually as as you can see here inside these directories such as this and download the
directory.
I have another directory with this custom name.
OK.
So if I want to actually create a directory by using my Java codes in Android or here I just need to
use this method here.
As you can see returns storage directory for folder name directory name and name a folder.
OK so I use the Smurfette in order to create a directory a custom directory in my and root directory
as you can see here in my storage.
OK.
So here inside is inside the body of the Smurfit I created an object of type find and the name of this
object is a file path.
OK so it's going to actually give me the path of the file new file here.
I want to create an object of type find an inside Apprentice's of this class.
Fine as you can see it is either apprentices of this class name.
So this is the constructor OK.
I actually first of all it refers to the environment of the Android device as you can see here.
Environment does get external storage public directory.
So it's going to give me access to these storage directory here as you can see so we can actually access
these files.
OK.
Get External storage public directory and inside Apprentice's I'll refer to the name of this directory
name for example.
I want to access the download directory.
OK so that's this argument directory name.
Come on.
And the second argument is name of the name of the folder that you want to create inside that directory.
For example these these are downloads and et cetera.
As you can see here and here I created an if else statement if file path that make directories.
If that actually did are the result of this expression is false.
If it cannot actually create a directory with this directory name and name a folder OK.
If this device is if this application cannot make a directory for actually creating a folder inside
this directory name as you can see here for example I have this download folder and I want to create
this directory and say This downloads folder.
If I cannot do that if file path that make directories as you can see here M-K deals stance will make
directories.
So if not file path here I referred to this object not to make directories.
If we cannot actually create a data directory to that specified directory name with that name or folder
then it's going I should execute this line of code here.
Let's create a toast so we can actually create this method here in a minute.
Let's create a toast and then it's going to the shortest message to the user.
There cannot be such directory in SD card.
OK.
Else.
Else if we can actually create a directory in our in that specific directory name with that specific
name or folder then it's going to actually show this message to the user.
Let's create a toast your folder is created and its name is name a folder.
OK.
And then it's going to return this file path to the color of this method OK file path.
So now this actually creates another method with this name.
Let's create a toast.
So here the public and the actually the return type of this method is Voyt and the name of this method
is list.
Let's create a toast.
And this is going to is going to actually accept one argument of type string as a class as you can see
here.
There's three in message.
And then I need to open and close this method by using these curly braces.
And inside this method I need to create a host object.
So as you can see here this is the line of code that I actually pasted here toast that may taste the
first argument is the context.
So I passed in the context for this activity main activity that this the second one is the message that
I want to show to the user and the first one is the duration of the message that I want to show to the
user.
And then I need to call the Shoma fed on this object.
OK.
So now as you can see the error is gone.
And remember that if we allow the user to access that the SD card in order to write some data on the
card or to read some data from the SD card.
OK then this Leffert is going I should return true.
And then it's going to allow me to access the directed specific directory and with that specific name
a name or folder and then it's going to show me this message your father is created and his name is
for example name a folder OK.
And if for example if the user denied to actually the application to used the SD card then this part
of the code is going to be executed if not a file path that makes directories so the user of the application
is not allowed to access the card and then dismiss it is going to be shown to the user.
There cannot be such directory in SD card.
OK.
Or if we have for example an order for their name in that specific directory name.
Again we cannot actually create an order for that in that in that directory and then it's going to again
show me this message.
There cannot be such directories in SD card.
So now artists actually go inside this and click method here.
And then there's actually I'm going actually pasting some lines of code here and then I'm going to explain
to you what's going on here.
So as you can see here these are the lines of code that I actually pasted here.
I created a switch statement inside this.
Unclear method.
So now I want to explain to you what's going on here.
First of all as you can see here I created a switch statement and inside the practices of the switch
statement I referred to the name of this argument that is of type view or key that we see from these
are unclear Smurfette.
OK the DOT get ID.
OK so it can actually switch between the IDs of the views or buttons as you can see here we have these
buttons or I am the animal here.
It's going to actually switch between those items and it can actually differentiate between those buttons.
OK.
So remember that button is actually a subclass of view.
OK so we can actually be fair to what happens as we use.
OK.
So that's why we could actually refer to this here.
That's good idea.
So it's going to switch between those buttons and then we can actually differentiate between the clicking
of the buttons that is inside our emulator here.
As you can see inside that application.
So for example we have we have this button here we have this button and defense buttons in our application.
So here for example case if our thought Id that's between download directory.
If for example the user clicks on this button let's make it directly to downloads folder OK.
If the user clicks on the spot in our That ID that's between download directory then it's going to actually
execute this line of code here.
Return.
So here I am referring to that specific method that that I actually created here as you can see here.
Return storage directory for folder name so you can actually create a directory inside this or that.
Inside the download directory that we have in our Android money.
So as you can see here inside our downloads folder we can actually create a directory.
So here as you can see I am saying that return storage directory for folder name environment directory
downloads.
So it can actually are repairing.
We can actually filter these are directory download environment that directory downloads.
And here for the second argument when it was specified a folder name.
So it can actually create a folder called Nice called nice downloads as you can see here inside the
directory downloads.
OK.
And then it's actually a break outside of this switch statement.
So let me explain again here we are calling this Smurfette return storage directory for folder name
environment that directory downloads.
So it's so it can actually create a directory inside this downloads directory here inside the storage
folder.
And we did this with this name.
Nice that.
OK.
So let's actually stop here and run our application and see what happens.
So as you can see here all of the application is actually running on this emulator.
And now if I want to actually make this keyboard this keyboard disappear I just click on this leather
triangle here and now as you can see this keyboard is gone.
And now as you can see I have this button.
OK let's make a that to download directory.
So I created as a case statement here case or that ID that between the download directory if the user
clicks on the spot and then it's going to execute this line of code here.
So let's actually click on this button here your folder is created and its name is nice downloads and
now it's actually open.
Are Android monitor as you can see here inside this download directory.
We have this folder.
Nice downloads as you can see here.
OK.
So now let's actually go back to what Android studio again here.
Here we have this case here are that idea that between music directory if the user clicks on this button
here let's make our directory to music folder.
Or that idea that music throatily then is going to actually execute this line of code here.
Return storage directory for folder name environment directory music.
OK.
So it's going to actually go inside this android monitor here as you can see if you have this music
directory as you can see here.
OK.
And then it can actually go inside this music directory.
So it's going to go inside is music directory as you can see here for example.
And then it's going to actually create a folder with this name.
Nice musics as you can see here.
And then it's going to break out of this switch statements.
So it's actually so.
Now in our are actually as you can see here in our emulator now to actually click on this button.
Let's make a directory to music folder.
So if I click on it now it says your folder is created and its name is nice musics.
So let's actually open our and rate monitor and now inside this music directory we can see this Walder
nice music.
OK.
And now we have another case statement here are that idea that PTEN documents folder.
So it's going actually as you can see here if the user clicks on the clicks on this button here let's
make a directory to documents folder.
Then it can actually create for example a folder with this name.
Nice documents inside this directory environment that directory documents.
And in our Android device monitor as you can see here.
If I open these documents folder here now you can see this file here.
Nice documents.
You can see this folder.
OK.
Nice comments.
And now we have another case statements case statement are that Id thoughts are between link ringtones
folder.
So if the user clicks on this button let's make our directory to our ringtones folder as you can see
here.
And then this line of code is going to be executed return storage directory for a folder name environment
that directory ringtones.
So it can actually go inside the house and really monitor as you can see here we have a directory called
ringtones.
As you can see here it's actually find districted here.
It is the directory.
And inside this directory is going to actually create a folder with that name.
Nine nice ringtones.
OK.
So let's actually go inside our emulator.
And now I want to actually click on the spot and let's make our directory touring tours folder.
And it says your folder is created and its name is nice.
All right ringtones.
And here we can see these folders.
Nice ring tones inside our ringtones directory.
And now let's get you to go inside.
These are Android stood you here.
And if you have these are that I.D. that Pythian pod cast for there.
Again this can actually go inside this podcast directory and then it's going to create this folder.
Nice podcasts.
So let's actually open our emulator here are here I want to actually create.
Click on this button.
Let's make a directory to podcast folder and it says your father is created and its name is nice podcasts
and now in our Android monitor let's actually find the podcast directory here.
For example this is our podcast directory.
And if I open it now we can see these folders nice podcasts.
And if I actually click on this button here again let's make a directory to podcast folder.
Now it says there cannot be such directory in SD card because we already have this folder with this
name here.
OK so it cannot actually create the same folder twice.
So let's actually go back inside our Android studio here we have movies folder here it's going to truly
create a directory environment that directory movies nice movies and plan for their environment that
created the alarms.
Nice alarms.
And here we have pictures for their environment that directory pictures nice pictures.
So let's go back in our hour emulator.
And now if we want to actually click on this button let's make a directory to move movies folder.
And it says your father is created and its name is.
Nice movies.
So now if I open our Android device monitor now here inside our movies folder we have these nice movies
directory as you can see here.
Now if I actually click on these for example this let's make I directed it to pictures folder.
Now if I actually open my pictures folder here it says Nice pictures.
Now if I actually click on this little match I directed it to alarm's folder again.
It's directory is created on here inside our alarm's folder.
I have these nice alarms here.
OK.
So hopefully that makes sense.
And now it's actually putting some more lines of code in our class and then I'm going to explain to
you what's going on here.
OK so now I want to actually save RTX the file in my Actually in my documents folder as you can see
here.
For example I went to actually typing typing something here in this on this textfield here and there
I want to actually click on these saved documents folder in as the cart button and then it can actually
create a text file in my documents folder.
So as you can see here in an Android device monitor here I have these documents folder and I want to
actually create a text file in these documents folder.
OK.
And then I'm going to actually put in the values that the user enter in say these are added text here
and then can actually put these values in that are certified.
OK.
So let's see how we can do that.
Let's go back to our Android studio and here I want to actually pasted our method here and then I'm
going to explain to you what's going on here.
So as the here this is them after they actually paste that here as you can see.
So as you can see here the access modifier of this method is public.
The return type of this Smurfit is void.
The name of the Smurfit is let's say file two documents folder and this if it doesn't accept any arguments
and as you can see here inside the body of the Smurfit I have these lines of code here.
First of all I created an object of type find.
OK.
And the name of this object is a file path.
So it's going to actually give me the file path to that specific defined so file file path assignment
operator new file.
So as you can see here inside the prentices environment that gets external storage public directories
so it can actually give me access to the SD card to get external storage or public directory environment
that directory documents.
So I want to actually access the documents folder and then I want to actually put this file in in that
directory.
Nice file that the.
So here we have a try catch exception exception here as you can see.
So inside this a statement as you can see I have file output stream.
So this object can actually help me to actually output some file to some directories to some files so
file path.
So so file output string and the name of this object is a file output stream new file output stream.
And here we need to pass the path that you want to actually save that object.
For example this nice find that 60.
So here is the path.
OK.
And here as you can see output stream writer.
OK so here I have an object of type output stream writer and the name of this object is output stream
writer.
So let's actually go back to our Android documentation and let's see what does these objects do ok for
example this file output stream or the output stream later.
So now let's actually open our browser and now our I mean the Android documentation developer that Android
dot com and inside the search bar here I want to actually search for file output stream.
So here as you can see I have this fight output stream here Android API.
And as you can see here this class is a public class and this class actually extends from the output
stream class.
OK.
And here as you can see this output stream class action is fight with stream class extends from this
output stream class and this output stream class extends from this object class.
So here we have some direct subclasses parsel file descriptor and auto output stream.
And here as you can see we have some oughtnt known indirect class subclasses assets file descriptor
and auto closed output stream.
So here is that is the description for this file output stream class of file output stream is an output
stream for writing data to a file or to a file descriptor whether or not a file is available or maybe
created depends upon the underlying platform.
Some platforms in particular allow a file to be opened for writing by only one file output stream or
other file writing object at a time.
In such situations the constructor in this class will fail if the file involved is already open.
OK so fall out with file output stream is meant for writing streams of raw bytes such as image data
for writing streams of characters.
Considering using file writer.
OK.
And here we have some summary.
Probably constructor's file output stream name file with stream name are boolean append.
So it creates a file with the output stream to write to the file with a specified name.
OK and we have file output stream file creates a file output stream to write to the file represented
by the specified file object.
If you have a fight with a stream file boolean append and here as you can see creates a file output
stream to write to the file represented by this specified file object file with the stream file descriptor.
OK.
And we have some public methods which we can use on the file output stream object as you can see here.
We have finalized Meffert and we have some other methods.
So here as you can see we used this method.
OK first of all I created an object of type file output stream and then as you can see I actually assigned
this path to the constructor.
So here as you can see we use this constructor here.
It creates a file output stream to write to the file represented by the specified object.
OK so here we have it out with the string here.
I created an output stream of writer object.
So let's see what the output stimulated right Optik outputs
stream writer so as you can see here inside the Android API we have this upped class output stream right
here.
And as you can see here this is a public class output stream.
Right.
And this class extends from the writer class.
And here it is there as you can see we can see that this output stream right the class is inheriting
all of the features and behaviors of this writer class and this writer class inherits all of the features
and behaviors of this object class.
And here we have known subclasses file writer.
So here is the description of this output stream right here and output stream writer is a breach from
characteris streams to byte streams characters written tweets are encoded into bytes using a specified
charset the charset that it used that it uses maybe specified by name or maybe even explicitly or the
platform's default charset may be except that each invocation of a right method causes the encoding
converter to be invoked on the given characters the resulting bytes are accumulated in a buffer before
being written to the to the underlying output stream.
The size of this buffer may be specified specified but by default it is a large enough for most purposes.
OK so if we can specify the size of the buffer but by default it is large enough for most purposes.
Note that the characters passed to the right methods are not buffered for top efficiency.
Consider wrapping an output string later within a buffer iterator so as to avoid frequent converters
invocations for example we have an example here as you can see and here we have some other descriptions.
So let's go back to what Android studio here.
We have an output stream right an object output stream new output stream file output stream.
Ok so it can actually convert this object file output stream into bytes.
As you can see here it says characters written to it are encoded into bytes.
OK.
And here we have actually DMF it's the constructor's as you can see here.
Output stream out with street and other constructors.
OK.
So here as you can see here I referred to the name of this object output stream right here.
That's the abend.
OK here I want to actually append some data to this output.
Inviter OK.
EDT value here.
I referred to this object.
It is de-value Let's actually open our emulator as you can see we have this Edhi text here.
I want to actually append the values that the user enter are in this text.
I want to append this value to this output assimilator object.
OK.
It is the body that takes the two strings.
OK.
And here I referred to the name of this object agame output stream right at that close.
So we need to close this output stream later and then we need to close this file output stream close
as you can see here we have to close this object before we actually reach the end of this curly braces
for this Troy statement.
As you can see here file output with streamlet close.
And then here I want to show a message to the user that the file is actually saved in the SD card.
OK.
Let's create a toast saved.
OK.
And that here we have a catch statement catch exception.
So if the if some errors happen during the for example saving the data out the in the SD card then it
can actually catch the exception lock that I lug it out with string so it's going to actually give me
a string representation of the exception that has occurred.
And then I want to show a message to the user.
Let's create a tossed exception occurred check the lock.
For more info.
Ok so now let's actually go back to our unclear method as you can see here.
Now I want to create another case statement.
Chase are thought Id dot PTEN.
Safe flight.
OK let's let me actually create a break statement here.
So if the user clicks on this for example it's opened the emulator.
If they use it click on the spot in say two documents folder in SD card.
OK I want to actually get the data that is inside this edit text here and then I want to actually save
it in a text file inside the SD card inside the documents folder documents directory.
So let's see how we can do that first because we have a method here that does actually do this job for
us saving that data to documents folder.
Here I just need to refer to the Smurfette.
And here I just can't just type in let's say file two documents folder.
OK.
And now let's actually run our project and see what happens.
So now as you can see here our application is actually running on this emulator.
OK.
And now here this is our textfield here.
This is our editor.
And now we want to actually for example type in my own name.
Mortiser.
And then let's let me actually disappear this keyboard and now I want to actually click on the spot
and save it to documents folder in as the cost.
And it is saved.
So let's actually open or open our Android device monitor.
And let's actually find the documents directory.
So this is our documents directory and this is my file.
Nice file that you see.
So remember in our Android studio when I actually created that Mefford let's say file to documents folder
as you can see here.
I decided to create a text file with this name.
Nice find and in an Android device monitor you can see these files.
So let's actually put this file in the on the desktop.
So I just need to click on this button and then here is going to ask me to save this file here.
I want to save it on the desktop and then click on Save.
So let's actually go back to our desktop.
So as you can see here this is my desktop and this is my file.
Nice file that takes the.
And now if I open it let's see what happens.
And as you can see here I have this value here mortars.
OK.
And that is the same value that I entered inside this edit text.
So now it's actually to change the value.
For example I want to type in another thing for example.
Nice.
And now let me actually make this keyboard disappear and if I click on this button again it says safe.
OK.
So let's actually open our Android device monitor again.
So as a test here this is my Android device monitor.
And here again I want to actually put this awide in my desktop.
So here I just need to select it and click on the spot in safe.
And now if I click double click on these textfile here again.
And now let me actually open this nice file that takes the fight again and here again we can see this
value.
Nice.
OK.
So hopefully that makes sense.
And now here I want to do another thing here here.
I want to let the user to click on this button retrieve the information from the SD card and then get
this value that is inside.
This takes the file and put it inside.
These are text view here.
OK.
So let's see how we can do that.
So let's actually open the Android studio.
So now I want to actually do another film here.
For example when the user clicks on these button as you can see here and the user clicks on this button
all you want to get the data that is inside that the inside of the file that we actually saved when
the user clicks on these CB2 documents folder in SD card.
I want to get those data that is actually inside of that specific to the file and then display it here
and these are tapes view here.
So in order to do that job here first need to actually create a method here inside of our main activity
class.
So after the end in curly brace of these or let's say five to eight commands for the effort he had to
actually create Smurfette.
OK.
So I'm going to paste in my fate on the head here and then I'm going to explain to you what's going
on here.
So as you can see here this is the method that they actually pasted here inside this main activity class.
OK.
So first of all let me tell you that the access modifier of this method is public.
The return type of this method is Voyt and the name of the Smif is let's retrieve five data up from
documents folder and this method is not going to accept any arguments.
So as you can see here inside the body of the Smurfette we have some lines of code here.
So first of all I created an object of type file.
OK.
And the name of this object is file path.
And as you can see here if you have an object of type find new file and inside the practices as you
can see environment does get external storage public directory.
So here you want to access the SD card environment that directory documents and you want to access the
documents folder inside the SD card.
So now as you can see for such an argument I need to actually give the name of the file.
Nice file that takes the.
So I can see here you have the next the same file here.
Nice file that.
As you can see.
But here inside the Smurfette let's say file two documents folder.
I just wanted to actually save this file inside the SD card but for the Smurfette in here I want to
actually get the data that is inside of this wide nice file that you XTi so be sure that that that the
name of this file is the same as the name of this flight that you actually put inside these let's say
filed two documents with their method.
So now as you can see here we have a try catch accept statement here OK try and here as you can see
inside these curly braces here I have an object of type file input stream.
OK.
And the name of this object these file input is Stream.
And here I want to actually create an object of type file file input stream by just putting the new
keyboard file input stream file path as you can see here.
So here I give this a file path here to the constructor of this flight input stream.
So let's actually go inside the documentation in order to see what is this fight input stream.
So file input string.
So here I can't just select it.
And now here is the documentation for this class.
And as you can see here this class is actually a public class.
And as you can see this class extends from the input stream class and now we have some direct some classes
and some and some indirect subclasses.
And here it says a file input stream obtains input bytes from a file in a file system what files are
available depends on the host environment file input stream is meant for reading streams of raw bytes
such as image data for reading streams of characters consider using a file reader.
So here is the summary file input stream.
And here we can see the constructors and here we can see the methods that is related to this class.
And now as you can see we have 5 input stream in order to read the data that is inside the nice fidelity
XTi.
And here I have a buffered reader object so buffered the reader here.
If you have a buffer to read or object as you can see here a new buffer the reader and as you can see
inside the prentices I created another object by putting the new keyboard new input stream reader.
So first of all let's go inside the documentation in order to see what is the Spofforth reader.
So let's actually open our browser here inside the search bar.
I just need to put this a class name buffer at the reader.
Double that.
Are you that Buffle reader inside the Android API eyes.
And now let's see what is this class Puplick class Spofforth reader extends the reader class OK.
And as you can see here it says Reith's text from a character input stream buffer into characters so
as to provide for the efficient reading of characters arrows and lines.
Def buffer size may be specified or the default size may be used.
The default is large enough for most purposes.
In general each read request made of a reader causes a corresponding greet request to be made up.
Underline character of byte stream.
It is therefore advisable to wrap a buffer reader around any reader who's read operations may be costly
such as file readers and input stream readers.
So as you can see here we have this example here.
So now let's actually go back to what I wrote stood studio.
So here we have the Spufford that object in order to read the data.
And here we have our input the stream reader.
OK so let's actually go inside the documentation in order to search for the input stream reader.
So let's actually click on it.
So now here you can see the documentation for input stream reader class as you can see this class extends
from the reader class and here it says an input stream reader is a breach from byte streams to the character
streams it reads bytes and decode them into characters using a specified charset the charset that it
uses may be specified by name or may be given explicitly or the platform's default charset may be accepted.
Each invocation of one of an input streams reader read methods may cause one or more bytes to be read
from the underlying byte input stream to enable the efficient conversion of bytes to characters more
bytes.
Maybe read ahead from the underlying string than are necessary to satisfy the current thread operation
for top efficiency.
Consider wrapping an input stream reader within a buffer the reader as you can see here.
So that's what what we actually done in our code buffer the reader input reader as you can see new Bufford
reader new input stream reader system that in.
So as you can see here in the Android studio you have a buffer entry that object.
And here I created a buffer object and here inside the prentices I created an input stream reader object
OK in order to read those characters.
And here I actually pass this file inputs to an object that I created.
Here are Trudy's constructor of this input stream reader class and here I created a variable of type
strain file data and then I assigned an empty value to this variable.
And here I created another variable called buffer data.
And then again I assigned an empty value to this variable.
And here I created a while loop so void first is going to actually execute this expression here.
White flight data as you can see is going to actually assign buffer the reader that read the line.
OK is going to try to read those data.
One line line line.
And that is going to assign those are they to this.
Why data are key and then is going to check whether those file data is not equal to null.
OK and then is can actually execute this line of code here.
Buffer date of assignment operator buffered data plus file data.
OK so he's going to actually assign these values to these for buffered data and then here I created
a newline character after each line.
OK so it's going to reduce the top line by line and then here.
I just wanted to put a newline character to read those lines of one but one line by line and that is
going to put a newline character after each line.
OK so now here as you can see I have this de-valued that said text buffered data.
So here I just want to assign this value buffer later to the sticks the value.
And then here I need to actually close this buffered leader here.
Discovery that object.
So I just referred to this object Bonfils reader that close.
So this is I'm afraid this is an instance of it that the OP could actually call on this object.
OK and here we have this catch exception here and here is connected if any error occurs while reading
the data from the SD card that is in.
That actually contains this nice file that you XTi then this block of code is going to be executed and
then add a description of the error is going to be actually shown ended up in the Lugg.
And here this toast message is going to be shown to the user.
Exception occurred.
Check log.
For more info.
So hopefully that makes sense.
And now let's actually go back in.
Unclear if it here and here at the end.
Let's actually create another case statement.
So case are that the DOT PTEN save file.
Ok BT and say find colon break and then here I can just call that method.
For example let's save file two documents folder.
I have this method and I have this.
Let's retrieve retrieve file data from documents folder.
So here I just need to call the Smurfit And as you can see here it's now showing us an error.
OK so let's actually hovered over the error area and see what's the error duplicate label.
So here we have our duplicate label.
I mistakenly I refered to this BT and say file here.
I just need to refer to the the name of the between.
Retrieve the info.
OK we have this button.
So let's actually go back to our emulator here.
As you can see retrieve the information from SD card.
So I just needed to refer to the Spartan in OK instead of referring to this button.
So here case are that ID that BT and retrieve the info are that ID data between retrieve the info.
And here we have this method.
Let's retrieve file data from Documents folder break.
So now let's actually run our project and see what happens.
So now as you can see our application is running on this emulator.
So now you want to actually click on this button retrieve the information from SD card.
So now as you can see I actually now see the value that was inside of the TXI the file that that I actually
saved inside my for SD card.
So here I just want to assign another value for example my name OK and then I just disappear this keyboard
and here I just want to click on the spot and save it to documents folder saved and then now I'm on
to click on this button.
Now I can see this value or I can actually type in another value.
Nice.
OK.
And then here I just need to click on the spot and save it to documents folder in SD card and now it's
saved.
And now if I click on the spot in it says Nice.
OK so this is how we can actually read data from the SD card.
And this is how we can actually save data to SD card.
OK so hopefully that makes sense.
And now let's actually add some other functionalities to this application.
Here I just want to add another functionality.
So when the user clicks on this image as you can see here I want to actually save this image in the
SD card.
OK so let's actually go back to our main activity that have a file here and again we need to add another
method for saving an image to SD card.
OK so now in order to save the image in SD card and then see that image in our Android device monitor
here I just want to create another method to do that job for me.
So here I'm going to paste in an effort and then I'm going to explain to you what's going on here.
So as you can see here this is the method that I actually paste that here and as you can see the access
modifier of this method is public.
There is anti-poverty Smurfette is void the name of this method is let's save the image to pictures
folder as you can see.
And now as you can see I created a straightedge exception and here inside a truck try Blatch.
I have a bitmap object.
OK bitmap bitmap bitmap factory that decode rissoles first double for the first argument.
We need to refer to the resources of our application.
So it gives resources.
And the second argument is the name of the image that is inside of the triable folder of our application.
So here I have our triable dot tiger.
OK.
So this image is inside the tribal folder of our project structure.
And here I have an object of type fight.
OK.
So the name of this object is flightpath.
And as you can see the data type of this object is filed.
Assignment operator new.
So here I want to create an object of type file.
OK.
New File.
And for the first argument as you can see here I just want to specify the directory that I want to actually
save the image.
So it environment that gets external storage public directory.
So here it's going to actually give me the access to SD card.
And here inside Apprentice's I need to specify the specific folder specific directory in my SD card
so environment that directory pictures.
So here I want to actually save my image to direct to the pictures.
OK.
Come on.
And here I need to actually specify that the name of the image that you want to actually save.
So here I need to specify the name of that image of this tiger image that you want to say inside that
directory pictures of my SD card.
As you can see Tiger underly image that PMG or I could actually change it to another name for example
Tiger want to free that P and G.
Ok here I specify the name and then it's very important that you actually put the piano here to in order
to specify the format.
And here I created an object of type output stream output stream new file output stream flightpath.
OK so here as you can see let's actually go back to our Android documentation.
In order to see what is this output stream object.
So here I just need to search for output string OK I have this output stream here.
So I just click on it.
And as you can see here public abstract class output stream.
So as you can see this class is abstract.
So if we cannot create an object of a type as it can see of type abstract K.B. cannot create directly
an object from this class.
And as you can see here here it says this abstract class is the superclass of all classes representing
an output stream of bytes an output stream accepts output bytes and send them to some scene.
OK.
Applications that need to define a subclass of output stream must always provide at least a method that
writes one byte of output.
OK so let's go back to our Android studio here.
Here as you can see I created an object here of type output stream as you can see.
So remember this class is an abstract class.
So here we need to actually refer to this flight output stream object.
OK.
Which is actually a subclass of output stream.
So let's go back to what Andrew documentation and says For find out food stream.
As you can see here I have this class here.
And as you can see file output stream actually directly inherits from this output stream class.
So here because this class is an abstract class and we cannot create an object of type with stream directly
here I created an object of type flight output stream.
And then I pass this final path to this class constructor flightpath.
OK.
And then here if there is a bitmap object that compress.
So remember we have a method called compress for bitmap objects.
First of all we need to specify our format of our image that we want to save.
Bitmap does compress formats that P and G.
Here we want to actually compress our image and save it.
Yes the cart.
So we need to call this method.
So the format of our image is PNB.
OK we could actually use other methods for example JPT or Tepic or other formats.
I choose and G.
And here we need to specify the quality of our image.
So 100 is good.
And here we need to pass the output stream object output stream in order to save that image to file
path.
OK.
And then we need to call this my method output stream that flash and out of the stream that close.
OK.
And then here we need to show our message to the user.
Your image has been successfully saved so let's actually go back to what Android documentation here.
In order to search for Flash Smurfette flush.
And here we can actually see that Meffert if you search for it let's actually go back to what our output
stream class in order to see the methods that are actually related to output stream.
So here as you can see we have the psalmody flush as you can see this Meffert flushes this output stream
and forces any buffered output bytes to be written out.
OK.
And we have a close MF'er closes this output stream and really says any system resources associated
with this stream.
OK so we needed to actually call this flush in order to actually it says that it flushes this output
stream and forces any buffered output bytes to be written out.
OK.
And here as you can see I just wanted to show a message to the user and we have a catch block here.
So if the program actually runs into error and if the program cannot actually save this image into SD
card into the collector the pictures then an error may occur and we can actually catch that error inside
this block.
And this is going to show me a description of that error and then put that error inside the lock.
And then it's going to show us and a tossed object exception occurred.
Check look for more info.
So let's actually go back to.
Inside these enclaves Mefford And here let's actually create another case statement here.
So case our thoughts ID dot BT G.
And so if the user clicks on that image ok for example this image as you can see here we have this image.
If the user clicks on this image then and when I do something break here and then here I just need to
call that and if it lets us save the image to pictures folder OK.
So let's actually run our project here and see what happens.
So as you can see here now our application is actually running on this emulator.
Let me actually make this keyboard disappear and now I want to actually click on this image here.
OK.
In order to save this image in the SD card.
So let's actually click on it and now it says your image has been successfully saved.
So let's actually open our Android device monitor as you can see here.
This is my Android device monitor inside these stories folder inside this emulated zero here.
As you can see I have these directories.
So let's actually search for the pictures directory as you can see here.
And inside these pictures directory.
I have this image Tiger I want to free that PMG.
So we managed to successfully save an image into SD card.
So hopefully that makes sense.
So let's actually go back to our Android studio and here I want to actually add some more functionalities
to our application here.
I just want to allow the user to actually click on the spot and allow access pictures in SD card.
So I want to actually add some pictures to my 3D SD card.
And then by just clicking on this button I want to let the user to see the images that we actually retrieve
from the SD card and put it inside on our inside the image switcher and sure the use user those images.
So in order to do that job we need to create another team effort let's actually scroll to the top of
our Java file here and here I want to actually declare two variables here.
So here I want to create an add a list of strange values.
So I just need to type in a list here.
And inside these angle brackets I need to specify the type of objects that I want to assign to this
area.
OK.
So at least as strange and the name of this array is going to be file path names.
OK so this is this array is going to hold.
Actually the names of the file paths OK.
And here I want to create another array of type find.
OK so find files.
So I just need to put a semicolon at the end of my statement.
So here I actually declared two objects.
OK the first one is an array list object of types three file pathnames.
And the second one is an array of file objects.
OK.
So let's actually go back inside this on create Smurfette.
And now I want to actually be fair to the name of this button BT and allow access Beecher's pattern
here.
So here I just need to type in PTEN allow access pictures.
That's set unclick listener.
So here I want to use an anonymous inner class.
OK.
So we allow access pictures that certainly isn't a new view.
So here as you can see I just need to choose this option.
Unclick listener.
And then it's going to create an anonymous class for me and that anonymous class is going to actually
implement this view that an uncle listener interface and then it's going to override this uncle uncle
my first for me.
OK so now I am inside an anonymous inner class.
OK.
And here inside that class inside that anonymous class I have this unclick method.
So now I can put my Ancoats here.