0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Android】SDカードが入っているかの判定

Posted at

SDカードが入っているかの判定

    if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
    // 外部ストレージ(SDカード)が使用可能な時の処理
    }

注意点:
外部ストレージの状態は、SDカードの抜き差しや、デバイスの再起動などで変化することがあります。
Android 6.0 (APIレベル23) 以上では、外部ストレージへのアクセスに権限が必要になります。事前に権限を確認し、必要に応じて権限を要求する必要があります。

パーミッションが必要な場合はAndroidManifestに以下を追加

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?