Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if the device possess an sdcard?

Tags:

android

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 ?

like image 752
Frankie Ribery Avatar asked Jan 02 '11 14:01

Frankie Ribery


People also ask

How do I know if my Android has an SD card?

Click "Start" and then "Computer" on your computer or laptop. Your Android SD card will be listed as a "Removable Disk" below the "Devices with Removable Storage" section.

Does my phone have a micro SD card?

As a rule, most Android and Windows Phone devices include a micro SD slot, usually located beside the SIM card slot on the back or side. Some phones don't have it, but it's pretty easy to check whether there is one or not (Remember it's a micro SD card you're looking for as a regular SD card won't fit).

How do I know if my Samsung phone has an SD card?

Android, simply check Settings > Storage (depending on the device) and it should have headings for internal and external storage. If there is an external storage header, that means that there is an SD card installed.


2 Answers

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.

like image 148
Zarah Avatar answered Sep 29 '22 22:09

Zarah


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!

like image 26
dondondon Avatar answered Sep 29 '22 23:09

dondondon