Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android offline

Android offline

In this talk we look at options/ways that we can benefit from Android Database and persistence.

make sure to checkout the Video of the presentation:
http://bit.ly/2RYjeGK

Avatar for Seyed Jafari

Seyed Jafari

June 05, 2019
Tweet

More Decks by Seyed Jafari

Other Decks in Technology

Transcript

  1. How? Persistence By persisting data we mean to store our

    data in a place that we can access it later even if system goes through restart/shutdown. Usually done by writing files on disks.
  2. File Pros and Cons Shared Preferences DataBase • No Structure

    • Bulk Read/Write • Easy (no need to learn) API • Binary data • Synchronized • Key-Value based • Small data • Framework Managed • Small API • Observing Changes (Surprised?) • Synchronized • OEM Bugs! • Structural • Transactional • Large Data sets • Relational • New API • Observing Changes • UnSynchronized • Lot’s of third party Libs
  3. Structured Query Language SQL / RDBMS / Relation Types of

    DataBases Non-SQL or non-relational No-SQL
  4. SQL Wikipedia: “ SQL is a domain-specific language used in

    programming and designed for managing data held in a relational database management system (RDBMS), or for stream processing in a relational data stream management system (RDSMS).”
  5. NoSQL Wikipedia: “ NoSQL database provides a mechanism for storage

    and retrieval of data that is modeled in means other than the tabular relations used in relational databases. ”
  6. Why to use Database on Android • Content received from

    remote data source (Caching) • User entered data and application generated data • Storing app states and User Management • Storing Requests and Works (WorkManager)
  7. ORMs • Native • Fully backward compatible • Small Size

    • Minimum method Count • Easy to migrate Pros • SQLite base • Very Slow • Not Fully Crossplatform • Not many features • Lots of people suggest not to use it any more Cons
  8. NoSQL DBs • Fast • Scalable • Constant Update •

    Fully featured • No more SQL • Cross platform • Easy to use Pros • Extra C binaries • Huge method count • Not Fully backward compatible(9/15) Cons
  9. Room • No Real Unit Testing Only Instrumentation test •

    In Memory DB Realm • No Real Unit Testing Only Instrumentation test • Mock master! • In Memory DB Objectbox • Write tests on JVM • No need to mock • Use real configuration not stub version
  10. DataBase Instance val store = MyObjectBox .builder() .androidContext(applicationContext) .build(); val

    box: Box<StudentEntity> = store .boxFor(StudentEntity::class.java)