はじめに
Androidタブレットで多量な画像ファイルと音楽ファイルを持ち歩きたいという要望から、WebViewを使って簡単なアプリを作ろうかとしたところ意外と苦労したので。。
タブレット端末の環境
Lenovo 501LV (Android 5.0.2, API21)
外部SDカードのパス
file:///storage/sdcard1
最初落とし穴は
「SDカード上のHTMLファイルを表示する」
でググったたこと、、
次に
Lenovo 501LVでは、getExternalStorageDirectory()
で
SDカードのパスがひろえなかった。。(機種によっては内部ストレージのパスを返すらしい)
で、最終的には
ログをちゃんとみてたら
D/Environment: getStorageVolume, volume:StorageVolume:
mStorageId=65537 mPath=/storage/emulated/0 mDescriptionId=17040812
mPrimary=true mRemovable=false mEmulated=true mMtpReserveSpace=10
mAllowMassStorage=false mMaxFileSize=0 mOwner=UserHandle{0} mUuid=null
mUserLabel=null mState=mounted
D/Environment: getStorageVolume, volume:StorageVolume:
mStorageId=131073 mPath=/storage/sdcard1 mDescriptionId=17040810
mPrimary=false mRemovable=true mEmulated=false mMtpReserveSpace=0
mAllowMassStorage=true mMaxFileSize=4294967295 mOwner=null mUuid=0403-0201
mUserLabel=null mState=mounted
mPath=/storage/sdcard1
(・・;)
ココでした。。
オワリ