4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

外付けSDカードにデータを保存

Posted at

##そもそも
Androidは外部SDに保存するパスがバラバラなので、あまり外部ストレージに保存するのは推奨されない。それでも保存したい時の話。
http://techbooster.org/android/application/16004/

##内部ストレージのパス
内部ストレージへのパスは
Environment.getExternalStorageDirectory()
メソッドで取得する。(メソッド名は外部っぽいけど内部)

##端末の外部ストレージのパス取得
端末を繋いだ状態でAndroid Studioのナビバーのドロイドくんをクリックし、Android Device Monitorを起動

/system/etc/vold.fstab を保存書き出ししてファイルをエディタで開く。

# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# NOTE: This file has been modified by Sony Mobile Communications AB.
# Modifications are licensed under the licence above.

dev_mount ext_card /storage/sdcard1 auto /devices/platform/msm_sdcc.3/mmc_host
dev_mount usbdisk /storage/usbdisk auto /devices/platform/msm_hsusb_host

最後の2行に外部ストレージのパスが書いてある。
この端末の場合
/storage/sdcard1 ← MicroSD
/storage/usbdisk ← USB Port

となる。

あとは内部ストレージと同じように使える。

参考)
http://nobuo-create.net/sdcard-2/

4
5
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
4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?