ANDROID: Accessing information from SQLiteDatabase in other classes?

前端 未结 1 498
南笙
南笙 2021-01-20 19:39

I have a separate class that includes the database, a cursor, and all the accessor methods for database information. I import the cursor into all the classes that update or

相关标签:
1条回答
  • 2021-01-20 20:19

    You can't access the database from another application, what you should do is create a ContentProvider if you want to expose this data to other apps.

    If you're trying to access it from within your application, create a wrapper DBHelper kinda class that access the SQLLite db, and have this be the ONLY class in your app touching the database directly, then expose methods to select, update, delete, etc. Other classes don't need to know about the database, they just deal with the DBHelper class and Java objects.

    0 讨论(0)
提交回复
热议问题