1

I have some queries which may be useful to others too. In android 4.0 onwards ,

1)how to check whether external sd card support is there or not ?

2)How to run Mediascan forcefully both internal and external memory ?

3)How to Mediascan only sd card or internal memory?

Vins
  • 4,089
  • 2
  • 35
  • 50
  • 1
    from `adb shell` run `mount` for a full view of what storage is mounted where on your device. – S.D. Nov 24 '12 at 06:27
  • Thanks , but i mean programmatically – Vins Nov 24 '12 at 06:31
  • Yes you can run `mount` from your app and get the result string , have a look at [this answer](http://stackoverflow.com/a/3350332/1531054). – S.D. Nov 24 '12 at 06:37
  • Your edit completely changed the question. But I tried giving a new response. – Warpzit Nov 26 '12 at 15:57

1 Answers1

1

I'd recommend reading storage options on developer.android.com.

To check external memory is available (taken from developer.android.com):

boolean mExternalStorageAvailable = false;
boolean mExternalStorageWriteable = false;
String state = Environment.getExternalStorageState();

if (Environment.MEDIA_MOUNTED.equals(state)) {
    // We can read and write the media
    mExternalStorageAvailable = mExternalStorageWriteable = true;
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
    // We can only read the media
    mExternalStorageAvailable = true;
    mExternalStorageWriteable = false;
} else {
    // Something else is wrong. It may be one of many other states, but all we need
    //  to know is we can neither read nor write
    mExternalStorageAvailable = mExternalStorageWriteable = false;
}

To read internal files use context.fileList(); see more here.

Edit

I'm not sure what you want with 2 and 3. You can use mediascan to many things but using it just for using it sounds unproductive. For that I'd recommend @Singularity advice. There is a post here about using mediascan for pdfs.

Community
  • 1
  • 1
Warpzit
  • 27,966
  • 19
  • 103
  • 155