Reading files from internal storage

In order to read a private file, get a FileInputStream by calling openFileInput(). This method takes a single argument—the name of the file to be read. openFileInput() must be called within an instance of Context. After retrieving a FileInputStream, you read bytes from the file by calling its read() function. Once you are done reading from the file, close it by invoking close().

Check out the following code:

private fun readFile(fileName: String) {
val stream: FileInputStream = openFileInput(fileName)
val data = ByteArray(1024)

stream.read(data)
stream.close()
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.195.111