【发布时间】:2011-06-19 08:22:16
【问题描述】:
我在关注Using your own SQLite database in your Android applications,在教程中作者提到我需要将sqlite文件复制到“默认系统路径”中:
//The Android's default system path of your application database.
private static String DB_PATH = "/data/data/YOUR_PACKAGE/databases/";
方法是:
/**
* Copies your database from your local assets-folder to the just created empty database in the
* system folder, from where it can be accessed and handled.
* This is done by transfering bytestream.
* */
private void copyDataBase() throws IOException{
我还阅读了该主题: Do all Android devices have an internal SD card
接受的答案是:
任何具有 Android 电子市场的设备都将在 Environment.getExternalStorageDirectory() 中拥有至少 2GB 的存储空间。是 SD 卡还是其他东西会因设备而异。
所以我想知道:
- “默认系统路径”是否与 Environment.getExternalStorageDirectory() 相同
- 我需要用 Environment.getExternalStorageDirectory() + “/YOUR_PACKAGE/databases”替换“/data/data/YOUR_PACKAGE/databases”吗?
我做了一个测试,在 Motorola Milestone(带有物理 QWERTY 键盘的那个)上打印出 Environment.getExternalStorageDirectory() 的结果并返回:
Dir: /sdcard
所以它们不一样,但是我应该使用哪一个来用于 SQLite 数据库?
谢谢!
【问题讨论】: