我的应用程序使用SQL数据库。如果我在AndroidManifest中声明android:installLocation="preferExternal"
,那么该数据库的位置会发生什么?它还会存储在外部数据库中吗?如果不是,那么我应该如何处理我的应用程序呢? (理想情况下,如果用户移动了应用程序,我也应该移动数据库)
答案 0 :(得分:2)
.apk文件保存在外部存储器中,但所有私有用户数据,数据库,优化的.dex文件和提取的本机代码都保存在内部设备内存中。
来自:http://developer.android.com/guide/appendix/install-location.html
数据库仍会保留在手机的内部存储空间中。你不必处理这个android会为你处理它
答案 1 :(得分:1)
回答其他问题。如果要将数据库放在外部存储上,请使用SQLiteDatabase.openDatabase方法,并将数据库的路径作为参数。检查以下链接。我找到了一些例子让你看看它们。
这是一个很好的!
Is it possible to move the internal DB to the SDCard?
这是另一个例子。
http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
你可能想用这些文件作为参考..祝你好运!
http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#openDatabase(java.lang.String,android.database.sqlite.SQLiteDatabase.CursorFactory,int,android.database.DatabaseErrorHandler)