1

getExternalStorageDirectory ()と の違いについて少し混乱していgetExternalStorageState ()ます。

getExternalStorageState ()Android ドキュメントについては、次のように言います。

public static String getExternalStorageState ()

プライマリ「外部」ストレージ デバイスの現在の状態を取得します。関連項目

getExternalStorageDirectory()

「外部」ストレージが利用可能かどうかについてこれを読んでいますが、文字列を返します。では、何の弦でしょうか?getExternalStorageDirectory()それがストレージへのパスである場合、「外部」ストレージと見なされるものへのパスを返すものとどう違うのですか? パスでない場合の「状態」とは何ですか?

誰かが違いを明確にしてもらえますか?なぜ一方を他方に使用するのですか?

4

1 に答える 1

4

http://developer.android.com/reference/android/os/Environment.htmlのドキュメントから(上部の定数セクションを参照):

String  MEDIA_BAD_REMOVAL   getExternalStorageState() returns MEDIA_BAD_REMOVAL if the media was removed before it was unmounted.
String  MEDIA_CHECKING  getExternalStorageState() returns MEDIA_CHECKING if the media is present and being disk-checked
String  MEDIA_MOUNTED   getExternalStorageState() returns MEDIA_MOUNTED if the media is present and mounted at its mount point with read/write access.
String  MEDIA_MOUNTED_READ_ONLY     getExternalStorageState() returns MEDIA_MOUNTED_READ_ONLY if the media is present and mounted at its mount point with read only access.
String  MEDIA_NOFS  getExternalStorageState() returns MEDIA_NOFS if the media is present but is blank or is using an unsupported filesystem
String  MEDIA_REMOVED   getExternalStorageState() returns MEDIA_REMOVED if the media is not present.
String  MEDIA_SHARED    getExternalStorageState() returns MEDIA_SHARED if the media is present not mounted, and shared via USB mass storage.
String  MEDIA_UNMOUNTABLE   getExternalStorageState() returns MEDIA_UNMOUNTABLE if the media is present but cannot be mounted.
String  MEDIA_UNMOUNTED     getExternalStorageState() returns MEDIA_UNMOUNTED if the media is present but not mounted.

これらの定数の 1 つを返します。

getExternalStorageDirectory()デバイスへのパス名を返します。

于 2013-08-16T19:05:16.397 に答える