使用自定义文件的Andr​​oid SQLite数据库自定义、数据库、文件、Andr

2023-09-06 13:34:54 作者:哪个骗子在写童话。 -

是否有可能选择的SQLite数据库文件自定义位置?

Is it possible to choose a custom location for the sqlite database file?

如果可能,我想存储在存储卡的数据库文件。如果从一个存储卡向其他用户交换机我想我的应用程序使用可用的卡上的数据库文件的任何版本。

If possible I want to store the database file in the memory card. And if user switches from one memory card to the other I want my application to use whatever version of the database file available on the card.

推荐答案

在默认情况下你的数据库是存储在数据/数据​​/ your_package /数据库

By default your database is stored in data/data/your_package/databases

您可以使用SQLiteDatabase openOrCreateDatabase在这里您可以提供的路径的自定义数据库作为第一个参数。

You can use SQLiteDatabase openOrCreateDatabase where you can supply the path to your custom database as your first argument.