Android Studio connect with existing SQLite database

无人久伴 提交于 2020-01-25 11:33:12

问题


i have one application with SQLite database and then i create another application that can connect to the database that i created one, my question is, is it possible connect the existing database without copying the existing once ? if possible can any one give me a sample code to connect my existing database . the name of my database is "SEIS" and the Table is Proinfo .


回答1:


By default, each app's files are private to the app.

You could tell Android that your two apps should get permission to access each other's files by setting the sharedUserId attribute for both and signing them with the same signature, but the 'official' way to give other apps access to your data is to create a content provider.




回答2:


Yes it is possible through the use of content providers. According to the documentation:

A content provider manages access to a central repository of data. A provider is part of an Android application, which often provides its own UI for working with the data. However, content providers are primarily intended to be used by other applications, which access the provider using a provider client object.

I suggest you read the following articles:

http://developer.android.com/guide/topics/providers/content-providers.html

http://www.tutorialspoint.com/android/android_content_providers.htm



来源:https://stackoverflow.com/questions/32816436/android-studio-connect-with-existing-sqlite-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!