1

What are some of the design options for the synchronizing the read/write of a sqlite database in an android app - something like what Google Analytics/Flurry libraries might be doing internally. They keep collecting data and send it to servers at the same time.

The app i am making collects data during app usage - and keep saving the data in a SQLite Database - and send this information to the backend - as and when the connection is available.

My question is how to design the SQLite DB access for the scenario when I might be writing to the app - while the app is sending data to the server. These events could happen at the same instance quite a number of times. I am not sure how do Google Analytics/Flurry work.

SyncAdapter / Content Provider / Plain SQLIte ?

user510164
  • 626
  • 1
  • 8
  • 17
  • possible duplicate of [Using Singleton design pattern for SQLiteDatabase](http://stackoverflow.com/questions/6905524/using-singleton-design-pattern-for-sqlitedatabase) – anddev84 Jan 15 '14 at 06:40

1 Answers1

1

This is a duplicate which actually has a very simple answer: android can single instance of SQLiteDatabase manage synchronization between multiple threads?

You can follow the SQLiteOpenHelper pattern, which you can learn more about in this very very thorough article and blog post.

Using Singleton design pattern for SQLiteDatabase

Community
  • 1
  • 1
anddev84
  • 1,473
  • 12
  • 30
  • I guess he already was using the same instance and he was talking about accessing this instance from different threads. Singleton has nothing to do with that... I don't understand why you mentioned it here – user25 Dec 31 '18 at 17:14