在 SD 卡上存储 Android 应用程序数据 [英] storing android application data on SD Card

查看:32
本文介绍了在 SD 卡上存储 Android 应用程序数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将安卓应用程序数据存储在 SD 卡上而不是内存中?我知道如何将应用程序sqlite数据库从内存传输到SDCard,但是如果内存首先被填满怎么办?大家都是怎么处理的?

Is there a way to store android application data on the SD card instead of in the internal memory? I know how to transfer the application sqlite database from the internal memory to the SDCard, but what if the internal memory gets full in the first place? How does everyone handle this?

推荐答案

警告: 此答案已过时.您应该使用 Environment.getExternalStorageDirectory() 来获取下面的答案中提到的 SD 卡的根路径.

Warning: This answer is out-dated. You should use Environment.getExternalStorageDirectory() to get the root path of the SD card as mentioned in the answers below.

旧答案,因此对此的评论是有道理的:

Old Answer so the comments on this make sense:

/sdcard/ 添加到根目录中,您的路径应该会引导您的 Android 应用程序使用 SD 卡(至少它与 G1 一起工作).Android 的文件系统对象使您能够检查文件大小......因此应该可以(如果棘手)编写一些故障转移代码.如果内存已满,此代码将调整您的根路径.

Adding /sdcard/ to the root your path should direct your Android application to use the SD card (at least it works that way with the G1). Android's file system objects give you the ability to check file sizes... so it should be possible (if tricky) to write some fail-over code. This code would adjust your root path if the internal memory filled up.

这篇关于在 SD 卡上存储 Android 应用程序数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆