Frankie Ribery
Frankie Ribery

Reputation: 12159

How to detect if the device possess an sdcard?

I forsee that my application will require the existence of a sdcard storage device. How do I query the device for a manifest of storage options ?

Upvotes: 6

Views: 5813

Answers (2)

dondondon
dondondon

Reputation: 901

This is working and very easy to understand

 TextView state = (TextView) findViewById(R.id.sdcardstatus);
  if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))   {
  state.setText("SD card is present");
} else {
 state.setText("SD card is not present");
 }

Or refer on this tutorial

HAPPY CODING!

Upvotes: 1

Zarah
Zarah

Reputation: 5189

You can use getExternalStorageState(). The developer site (linked here) has a short snippet of the recommended way to check for the presence of the external SD card, and whether or not you can write to it.

Upvotes: 5

Related Questions