真実の楽譜(フルスコア)

プログラム関係の忘備録になるはず

AndroidはKitKat以降アプリからSDカードへの書き込み不可に?

2014/01/30 18:30 内容一部修正

KitKat端末では今後アプリからMicro SDカードへの書き込みができくなる模様 | juggly.cn
この記事もうちょっと詳しく調べてみた。

情報元ソース

元ソースはGoogle+Google社のTod Liebeck氏書いた内容

KitKat will make your SD Card completely useless: per the Android API specification, apps can no longer write files to your SD card. And Samsung is following it.

This only applies to dual-storage devices, i.e., devices with a user-writable internal flash storage AND a removable SD card.


From http://source.android.com/devices/tech/storage/index.html:

"The WRITE_EXTERNAL_STORAGE permission must only grant write access to the primary external storage on a device. Apps must not be allowed to write to secondary external storage devices, except in their package-specific directories as allowed by synthesized permissions."


If your device has user-accessible internal flash storage, your SD Card is a "secondary external storage device".


What this means is that with KitKat, applications will no longer be able create, modify, or remove files and folders on your external SD card. As a for-instance, you can no longer use a file manager to copy files from your computer to the SD card over a network. This ability, which has existed since the beginning of Android, has been taken away.


The only stated reason for this removal of functionality is that, "Restricting writes in this way ensures the system can clean up files when applications are uninstalled." I do not pretend to understand this logic. Apps are still allowed to write in arbitrary directories on the primary storage (with the appropriate permission), but are denied the same access to external storage.


Samsung has implemented this feature with their KitKat OTA updates. Note3 users are now complaining that FX File Explorer can no longer write to their external SD cards. There are solutions to this problem for users with root access. Users without root access appear to be screwed.

I'm not quite certain how Google intends for you to place files on your SD card. Perhaps you have to use proprietary Google apps that contain permissions unavailable to the rest of the developer world. Perhaps you're supposed to put everything on the cloud and pay carrier data fees to get it there. Perhaps you're supposed to use some kind of WIRE to attach your WIRELESS device to your computer and have the computer do that work for you.


In my opinion this is a horrible misstep by Google and the Android Open Source Project. Functionality has been removed without reason, to the severe detriment of users and developers alike.


I apologize for not bringing this to everyone's attention when KitKat 4.4 was released, but it was not mentioned in the Android 4.4 changes document: http://developer.android.com/about/versions/android-4.4.html. It's only mentioned in the article on source.android.com. I was only made aware of its existence from user reports as a result of Samsung implementing this change in its KitKat OTA updates.

https://plus.google.com/+TodLiebeck/posts/gjnmuaDM8sn

要約

翻訳ミスがあるかもしれないので注意してね。

KitKatから仕様変更
  • アプリはSDカードへの書き込みが完全にできなくなる
  • (例)ファイルマネージャーアプリでファイルをSDカードに保存できなくなる
  • サムスンはGALAXY Note3のアップデートで追従した
デュアルストレージデバイスが対象
  • 対象はフラッシュストレージと取り外し可能なSDカードを持つデバイス
  • WRITE_EXTERNAL_STORAGEパーミッションでは、主要なストレージのパッケージ固有ディレクトリにしか書き込めない
  • WRITE_EXTERNAL_STORAGEパーミッションがあれば主要なストレージ内のどこにでも書き込みが可能 (2014/01/30 18:30 修正)
  • SDカードは2番目の外部ストレージになり書込みが許可されない
  • SDカードは2番目の外部ストレージになりパッケージ固有ディレクトリにしか書込みが許可されない (2014/01/30 18:30 修正)
  • root権限がないと回避できない
仕様決定理由
  • 書込みを制限させ、アプリのアンインストール時に完全にクリーンアップできるから
Tod Liebeck氏は不満
  • 今後Googleがどうしたいかはわからない
  • でも代価としてクラウドサービスとかを用意して金取るかも
  • オープンソースプロジェクトとして失策
  • 変更内容に書かれてなくてサムスンのアップデートで知ったごめん

修正について

完全に書き込みができないのではなく、
SD内のアプリケーションのパッケージ固有ディレクトリ[SD\Android\data\パッケージ名\]
なら保存できるってのが正確な仕様のようです。

The WRITE_EXTERNAL_STORAGE permission must only grant write access to the primary external storage on a device. Apps must not be allowed to write to secondary external storage devices, except in their package-specific directories as allowed by synthesized permissions. Restricting writes in this way ensures the system can clean up files when applications are uninstalled.

External Storage Technical Information | Android Developers

Tod Liebeck氏が

KitKat will make your SD Card completely useless

KitKatではSDカードが完全に使えなくなる」
って書いていて矛盾してるのは記述ミスなんだろうか?