Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我编写了一个具有后台服务的 android 应用程序,可以在应用程序未运行时进行数据同步。如何使用该服务修改内部内存中的文件或 Android 应用程序的 sqlite 数据库中的记录。
你做的就像你在一个普通的应用程序中一样,因为你是在一个Context. 我要指出的重要一点是,如果您的应用程序启动并且您Service也启动并且两者都需要使用数据库,那么您需要确保不会发生冲突。您可以简单地将您的实例存储在您的子Application类中,以确保只创建了一个数据库实例。
Context
Service
Application