External Storage
External Storage:
The concept of external storage with reference to android is an area of storage that is not part of the internal memory of the portable device.
It could be an SD card or any other removeable storage device as they are usually used in mobile phones and other portable devices. a) External storage is another means through which storage space is provided to the user so as to store his images, videos, documents, data etc.
Example:
// AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
// activity_external_storage_example.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ExternalStorageExample"
android:padding="16dp"
android:gravity="center"
android:orientation="vertical">
<EditText
android:id="@+id/input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter your message" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="16dp"
android:gravity="center">
<Button
android:id="@+id/b1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save Data"
android:textColor="@color/colorWhite"
android:textAllCaps="false"
android:background="@color/colorOrange"
android:padding="16dp"
android:layout_margin="16dp" />
<Button
android:id="@+id/b2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Display Data"
android:textColor="@color/colorWhite"
android:textAllCaps="false"
android:background="@color/colorOrange"
android:padding="16dp"
android:layout_margin="16dp" />
</LinearLayout>
<TextView
android:id="@+id/textDisplay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/colorAccent"
android:textSize="20dp"
android:padding="16dp"
android:gravity="center" />
</LinearLayout>
Output