Android - 从网上更新app中的数据库

时间:2023-01-19 15:28:27

I have an app with a database full of information. The user never changes or adds anything to this database. I would like to update the database myself and store it on the web. Then everytime the app loads, it will check the web for a new version. If there is one, it would simply download it and replace it. What is the best way of doing this?

我有一个带有充满信息的数据库的应用程序。用户永远不会更改或添加任何内容到此数据库。我想自己更新数据库并将其存储在网络上。然后每次加载应用程序时,它都会检查Web是否有新版本。如果有,它只需下载并替换它。这样做的最佳方式是什么?

4 个解决方案

#1


2  

Someone else will have to tell ya the best way to initiate the actual download, but this blog post may be helpful in figuring out how to install the database once downloaded.

其他人必须告诉您启动实际下载的最佳方式,但此博客文章可能有助于确定下载后如何安装数据库。

Also, you may find this question I posted earlier useful in determining database versions, basically I'm just parsing the file name to determine version. I'm sure there's an easier way for you though if you're communicating with a server.

另外,您可能会发现我之前发布的这个问题对确定数据库版本很有用,基本上我只是解析文件名以确定版本。如果你正在与服务器通信,我相信你会有更简单的方法。

#2


1  

You got several options to tackle this problem:

您有几种方法可以解决此问题:

  1. Download a xml or json file from your webserver, parse it, clear current database and import new data.
  2. 从Web服务器下载xml或json文件,解析它,清除当前数据库并导入新数据。
  3. You could directly save a text file on your webserver with sql statements and directly execute this prepped sql file to you sqlite database.
  4. 您可以使用sql语句直接在Web服务器上保存文本文件,并直接将此准备好的sql文件执行到sqlite数据库。

#3


0  

Well, you can update the whole apk via internet just checking it's version and checksum, and every new version should contain new DB version and necessary instructions which can be executed with a little help of SQLiteOpenHelper Or you can update your db via simple XML container over HTTP...

好吧,你可以通过互联网更新整个apk只检查它的版本和校验和,每个新版本应该包含新的数据库版本和必要的指令,可以在SQLiteOpenHelper的帮助下执行或者你可以通过简单的XML容器更新你的数据库HTTP ...

#4


0  

you can have a separate table in each dbs to keep the version updating. so every time you load the app you can call a web service and get the current version of the db which you store in the web server. if its newer than the db which you have, you can simply replace it.

您可以在每个dbs中有一个单独的表来保持版本更新。因此,每次加载应用程序时,您都可以调用Web服务并获取存储在Web服务器中的当前版本的数据库。如果它比你拥有的数据库更新,你可以简单地替换它。

you can use .Net web service which has the method to get the version of the db which stores in web, and with the help of ksoap library you can invoke the .Net web service and get the results.

您可以使用.Net Web服务,该服务具有获取存储在Web中的db版本的方法,并且在ksoap库的帮助下,您可以调用.Net Web服务并获取结果。

#1


2  

Someone else will have to tell ya the best way to initiate the actual download, but this blog post may be helpful in figuring out how to install the database once downloaded.

其他人必须告诉您启动实际下载的最佳方式,但此博客文章可能有助于确定下载后如何安装数据库。

Also, you may find this question I posted earlier useful in determining database versions, basically I'm just parsing the file name to determine version. I'm sure there's an easier way for you though if you're communicating with a server.

另外,您可能会发现我之前发布的这个问题对确定数据库版本很有用,基本上我只是解析文件名以确定版本。如果你正在与服务器通信,我相信你会有更简单的方法。

#2


1  

You got several options to tackle this problem:

您有几种方法可以解决此问题:

  1. Download a xml or json file from your webserver, parse it, clear current database and import new data.
  2. 从Web服务器下载xml或json文件,解析它,清除当前数据库并导入新数据。
  3. You could directly save a text file on your webserver with sql statements and directly execute this prepped sql file to you sqlite database.
  4. 您可以使用sql语句直接在Web服务器上保存文本文件,并直接将此准备好的sql文件执行到sqlite数据库。

#3


0  

Well, you can update the whole apk via internet just checking it's version and checksum, and every new version should contain new DB version and necessary instructions which can be executed with a little help of SQLiteOpenHelper Or you can update your db via simple XML container over HTTP...

好吧,你可以通过互联网更新整个apk只检查它的版本和校验和,每个新版本应该包含新的数据库版本和必要的指令,可以在SQLiteOpenHelper的帮助下执行或者你可以通过简单的XML容器更新你的数据库HTTP ...

#4


0  

you can have a separate table in each dbs to keep the version updating. so every time you load the app you can call a web service and get the current version of the db which you store in the web server. if its newer than the db which you have, you can simply replace it.

您可以在每个dbs中有一个单独的表来保持版本更新。因此,每次加载应用程序时,您都可以调用Web服务并获取存储在Web服务器中的当前版本的数据库。如果它比你拥有的数据库更新,你可以简单地替换它。

you can use .Net web service which has the method to get the version of the db which stores in web, and with the help of ksoap library you can invoke the .Net web service and get the results.

您可以使用.Net Web服务,该服务具有获取存储在Web中的db版本的方法,并且在ksoap库的帮助下,您可以调用.Net Web服务并获取结果。