作者:路很长别太狂_297 | 来源:互联网 | 2023-05-18 03:47
MyAndroidappisreadingandwritingtoalocalSQLiteDBfromafewdifferentActivitiesandaSer
My Android app is reading and writing to a local SQLite DB from a few different Activities and a Service. Pretty standard. But I'm not happy with the way I've got all the DB details stored as constants that I then use anywhere I access the DB. I've been advised to wrap the DB in a ContentProvider. Sounds good to me. While I'm refactoring my code, I figured I'd ask:
我的Android应用程序从一些不同的活动和服务中读写到本地的SQLite DB。非常标准的。但是我不喜欢把所有的DB细节都存储为常量,然后在访问DB的任何地方使用。有人建议我将DB包在一个内容提供程序中。听起来不错。当我重构代码的时候,我想我会问:
- What are your best practices for local DB data storage in Android?
- Android中本地DB数据存储的最佳实践是什么?
- Where and how do you store "CREATE TABLE" statements, column names, other SQL?
- 在何处以及如何存储“创建表”语句、列名和其他SQL?
- Would you mind sharing a list of the classes you instantiate and what goes into each (ContentProvider, DatabaseProvider, DatabaseHelper...)?
- 您是否介意共享实例化的类的列表以及每个类的内容(内容提供者、数据库提供者、数据库助手…)?
- How do you coordinate the structure of your local Android DB with a server-side DB available through a REST interface?
- 如何协调本地Android DB的结构与通过REST接口提供的服务器端DB ?
Yeah, I realize I'm getting at the perennial "where's the Android object-relation-mapping framework?" question. For now, I'm mainly curious to hear how you structure your Android apps with what's available in the standard SDK.
是的,我意识到我一直在问“Android对象-关系-映射框架在哪里?”现在,我主要想知道如何用标准SDK中可用的方式来构建Android应用程序。
As always, thanks for the pointers!
一如既往,谢谢你的指点!
5 个解决方案