简体   繁体   English

从两个不同的应用程序访问数据库

[英]Accessing database from two different apps

I am creating a Premium edition of an app for which I already released a free Lite edition. 我正在创建一个应用程序的高级版,而我已经为其发布了免费的精简版。 I want to either transfer the data from the Lite edition into the Premium edition or have both editions access the same database. 我想将数据从精简版传输到高级版,或者让两个版本都访问同一数据库。 Android, two apps one database? Android,两个应用程序一个数据库? helped answer how to do the later. 帮助回答了以后的操作。 If the database is created in the Lite edition, what happens when the user installs the Premium edition? 如果数据库是在精简版中创建的,那么当用户安装高级版时会发生什么? Do they have to keep the Lite edition installed in order to keep the data? 他们是否必须保留Lite版本才能保留数据? On the other hand, can I create the database in a location that is independent of either edition but is still sandboxed? 另一方面,我可以在独立于两个版本但仍处于沙盒状态的位置创建数据库吗? Ultimately, I want to be able to allow the user to remove the Lite edition after they install the Premium one but still keep all the data intact. 最终,我希望能够允许用户在安装Premium版本后删除Lite版本,但仍保留所有数据不变。 How do I do this? 我该怎么做呢? Or am I stuck with making my users keep both editions installed even after they upgrade to the Premium edition? 还是我坚持让我的用户在升级到高级版后仍然安装两个版本?

I would recommend at least looking into CouchDB for hosting the data. 我建议至少考虑使用CouchDB托管数据。 You create your data as documents (in JSON) and then you create databases that contain documents. 您将数据创建为文档(使用JSON),然后创建包含文档的数据库。

In addition you can create views on your data - http://wiki.apache.org/couchdb/HTTP_view_API . 另外,您可以在数据上创建视图-http: //wiki.apache.org/couchdb/HTTP_view_API You can pass in parameters to the views to filter data etc. 您可以将参数传递给视图以过滤数据等。

You can create a sample CouchDB with Cloudant ( https://cloudant.com/ ) or IrisCouch ( http://www.iriscouch.com/ ). 您可以使用Cloudant( https://cloudant.com/ )或IrisCouch( http://www.iriscouch.com/ )创建一个示例CouchDB。 I know Cloudant supports HTTP authentication so you can make all your calls look like this from the Android device: 我知道Cloudant支持HTTP身份验证,因此您可以通过Android设备使所有呼叫看起来像这样:

http://user:password@yourdomain.com/database

Another option is to look at TouchDB which handles replication from CouchDB for you. 另一个选择是查看TouchDB,它可以为您处理从CouchDB进行的复制。 https://github.com/couchbaselabs/TouchDB-Android Keep in mind the project is a little behind right now, so I don't think it's production ready, but they're focusing heavily on it this year, so it should be coming along shortly. https://github.com/couchbaselabs/TouchDB-Android请记住,该项目现在有点落后,所以我认为它尚未投入生产,但他们今年将重点放在该项目上,因此应该很快就会来。

Just an option for putting up a shared database with authentication. 这只是通过身份验证建立共享数据库的一种选择。 Then you could host the same data and leave the lite vs. premium stuff strictly in the UI. 然后,您可以托管相同的数据,并将精简版和高级版内容严格保留在UI中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM