Home » Android External Storage Example

Android External Storage Example

by Online Tutorials Library

Android External Storage Example

Like internal storage, we are able to save or read data from the device external memory such as sdcard. The FileInputStream and FileOutputStream classes are used to read and write data into the file.


Example of reading and writing data in the android external storage

activity_main.xml

Drag the 2 edittexts, 2 textviews and 2 buttons from the pallete, now the activity_main.xml file will like this:

File: activity_main.xml

Provide permission for the external storage

You need to provide the WRITE_EXTERNAL_STORAGE permission.

File: Activity_Manifest.xml

Activity class

Let’s write the code to write and read data from the android external storage.

File: MainActivity.java

Android External Storage 1 Android External Storage 2

You may also like