简体   繁体   English

从android中的另一个应用程序更新一个应用程序的数据库

[英]update database of an app from another app in android

I need to update and insert rows in Sqlite from another app. 我需要从另一个应用程序在Sqlite中更新和插入行。 I am working on an android app and I have to update database of another app,how can I do that,is it possible to access and edit another app's database from my app. 我正在开发一个Android应用程序,因此必须更新另一个应用程序的数据库,该怎么做?是否可以从我的应用程序访问和编辑另一个应用程序的数据库。

You should look at Content Providers. 您应该查看内容提供者。 From the android official docs 来自android 官方文档

Content providers manage access to a structured set of data. 内容提供商管理对结构化数据集的访问。 They encapsulate the data, and provide mechanisms for defining data security. 它们封装数据,并提供定义数据安全性的机制。 Content providers are the standard interface that connects data in one process with code running in another process. 内容提供者是将一个进程中的数据与另一个进程中运行的代码连接的标准接口。

Android Docs explain how you can use it. Android文档说明了如何使用它。

I understand what you are trying to achieve. 我了解您要达到的目标。 correct me if i am wrong. 如果我错了,请纠正我。 You are developing android application in which you are trying to update your application database by fetching data from some different database. 您正在开发android应用程序,您正在其中尝试通过从其他数据库中获取数据来更新应用程序数据库。 right? 对? if yes, you have to get details of the database server /database connection details from the database owner if possible. 如果是,则必须尽可能从数据库所有者那里获取数据库服务器/数据库连接详细信息。 in case if the owner of the database is not providing or not ready to give you credentials/database connection details then confirm whether they have any services/webAPI/web services through which they expose database data. 如果数据库的所有者没有提供或未准备好为您提供凭据/数据库连接详细信息,请确认他们是否具有通过其公开数据库数据的任何服务/ webAPI / web服务。 If they have webapi/webservices available then you can easily consume in your andriod application and do what ever operation you want to perform. 如果他们有可用的webapi / webservices,那么您可以轻松地在您的Andriod应用程序中使用它并执行您想执行的任何操作。

Hope this helps.. 希望这可以帮助..

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

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