SQLite数据库存储 [英] Sqlite Database storage
问题描述
这可能是一个愚蠢的问题要问,但我仍需要知道它的确切答案。当我们创建一个数据库为特定的应用程序和部署一个真正的设备上的应用程序,哪里是数据库系统创建的?在内部存储或SD卡上?如果其在内部存储默认,可我们它转移到SD卡,因为该应用可能会崩溃,由于低的内部存储器并提高数据库的大小。我有一个DB与9列的表。会在哪里存放数据库的正确位置?
This may be a stupid question to ask, but still I need to know the exact answer of it. When we create a DB for a particular app and deploy that app on a real device, where is the DB created by the system? On the internal storage or on the SD card?? If its on the internal storage by default, can we shift it to the SD card, because the app might crash due to low internal memory and increasing DB size. I have one DB with a table with 9 columns. Where would be the correct location to store the DB?
推荐答案
如果你不使用 SQLiteOpenHelper
创建数据库时提供任何特定的路径,那么这将(默认)存储它在设备的内存:
If you dont provide any specific path during creating database using SQLiteOpenHelper
, then it will (default) store it in device's internal memory:
数据/数据/ app_package_name /数据库/ dbFilename
data/data/app_package_name/databases/dbFilename
不过,您可能会在创建数据库时,提供自己的路径/位置太过于如
However, you may provide your own path/ location too when creating database, for e.g.
/*creating database in SD card under app's cache directory*/
context.openOrCreateDatabase(context.getExternalCacheDir() + "/dbFileName",
Context.MODE_PRIVATE, null);
这篇关于SQLite数据库存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!