如何将现有的MS Access移植到SQLite以与android app developpement一起使用? [重复]

时间:2021-08-26 18:13:35

Possible Duplicate:
How to convert MDB to SQLite in Android

可能重复:如何在Android中将MDB转换为SQLite

I have an MS access database with few tables and quite a bit of data in it. I was wondering if it is possible for me to port all those tables over to sqlite for an android app that I am developing.

我有一个MS访问数据库,里面有很少的表和相当多的数据。我想知道我是否有可能将所有这些表移植到sqlite以获取我正在开发的Android应用程序。

Thanks for your time

谢谢你的时间

1 个解决方案

#1


6  

The easiest way would be to export each table to CSV and then use an SQLite tool of some sort to import those tables into your SQLite database. I use SQLite Expert.

最简单的方法是将每个表导出为CSV,然后使用某种SQLite工具将这些表导入SQLite数据库。我使用SQLite Expert。

Then you would need to make some modifications to that database and those tables to make it usable by Android to populate listviews and other widgets.

然后,您需要对该数据库和那些表进行一些修改,以使Android可以使用它来填充listviews和其他小部件。

1) The database must contain a table called "android_metadata"
2) This table must have the column "locale"
3) There should be a single record in the table with a value of "en_US"
4) The primary key for every table needs to be called "_id" (this is so Android will know where to bind the id field of your tables)

1)数据库必须包含一个名为“android_metadata”的表2)该表必须具有“locale”列3)表中应该有一个值为“en_US”的记录4)每个表需要的主键被称为“_id”(这是Android将知道绑定表的id字段的位置)

Then you put the DB in your assets folder and when your app starts copy it to your apps data directory.

然后将数据库放在资源文件夹中,当应用程序开始将其复制到您的应用程序数据目录中。

A good link for this copying process is here.

这里是这个复制过程的一个很好的链接。

You could also use SQLiteAssetHelper to handle the transfer of the DB from assets to your data directory instead of doing the way the tutorial shows if you felt the need.

您还可以使用SQLiteAssetHelper来处理数据库从资产到数据目录的传输,而不是按照教程显示的方式进行处理。

#1


6  

The easiest way would be to export each table to CSV and then use an SQLite tool of some sort to import those tables into your SQLite database. I use SQLite Expert.

最简单的方法是将每个表导出为CSV,然后使用某种SQLite工具将这些表导入SQLite数据库。我使用SQLite Expert。

Then you would need to make some modifications to that database and those tables to make it usable by Android to populate listviews and other widgets.

然后,您需要对该数据库和那些表进行一些修改,以使Android可以使用它来填充listviews和其他小部件。

1) The database must contain a table called "android_metadata"
2) This table must have the column "locale"
3) There should be a single record in the table with a value of "en_US"
4) The primary key for every table needs to be called "_id" (this is so Android will know where to bind the id field of your tables)

1)数据库必须包含一个名为“android_metadata”的表2)该表必须具有“locale”列3)表中应该有一个值为“en_US”的记录4)每个表需要的主键被称为“_id”(这是Android将知道绑定表的id字段的位置)

Then you put the DB in your assets folder and when your app starts copy it to your apps data directory.

然后将数据库放在资源文件夹中,当应用程序开始将其复制到您的应用程序数据目录中。

A good link for this copying process is here.

这里是这个复制过程的一个很好的链接。

You could also use SQLiteAssetHelper to handle the transfer of the DB from assets to your data directory instead of doing the way the tutorial shows if you felt the need.

您还可以使用SQLiteAssetHelper来处理数据库从资产到数据目录的传输,而不是按照教程显示的方式进行处理。