private IMountService mMountService; mMountService = getMountService(); private synchronized IMountService getMountService() { if (mMountService == null) { IBinder service = ServiceManager.getService("mount"); if (service != null) { mMountService = IMountService.Stub.asInterface(service); } else { Log.e(TAG, "Can't get mount service"); } } return mMountService; } //format sdcard mMountService.formatMedia(Environment.getExternalStorageDirectory().toString()); //unmount sdcard mMountService.unmountMedia(Environment.getExternalStorageDirectory().toString());