You need to be more specific than "does not worked".
- What was the behaviour you discovered?
- Did you get an error, or did you get zero?
- Were you using an emulator or a device?
- Were you using a system with multiple external storage?
A good example: Android get free size of internal/external memory
Also, the USB device is difficult to detect, if the default storage is not set to the USB device. All the Environment.* folder/path APIs will return the
Ref: http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory()
Note: don't be confused by the word "external" here. This directory
can better be thought as media/shared storage. It is a filesystem that
can hold a relatively large amount of data and that is shared across
all applications (does not enforce permissions). Traditionally this is
an SD card, but it may also be implemented as built-in storage in a
device that is distinct from the protected internal storage and can be
mounted as a filesystem on a computer.
And then there is another API that may be what you are looking to check instead of data-directory.
Ref: http://developer.android.com/reference/android/os/Environment.html#getExternalStoragePublicDirectory(java.lang.String)
Here's Motorola with their specific API for handling such cases, but again that may not be what you are looking for depending on your particular problem: http://developer.motorola.com/docs/motorola-external-storage-api/
In Any case, I hope this would help with your problem. If not, please provide more information and the great guys at StackOverflow will help in their usual great way.
Hope this helps.