08 App Mobile Teo Local Persistence(1)
08 App Mobile Teo Local Persistence(1)
Local Persistence
Course: 105025-2425
Contents
Sprint 01 - Feedback
Persistence
SqlLite
Room
Hands On
Sprint 03
Puntos Importantes
• Uso de la IA
• Copyright (c) 2025 [Your Name or Organization]
• Organización del Proyecto (Nombres x Documentación)
• Release v.0.1.0 vs v1.0.0 (semver.org)
• No creación de las clases de dominio (domain/)
• Bugs al compilar
What
• The repository pattern is a structural design pattern. It’s instrumental for organizing how you access data.
• A repository defines data operations. The most common operations are creating, reading, updating, and deleting
data, (also known as CRUD).
• The repository pattern was first introduced in 2004 by Eric Evans in his book, Domain-Driven Design: Tackling
Complexity in the Heart of Software.
Why
• Serves as an intermediary layer between the data source and business logic.
• Simplifies data access and management without binding the app to a specific technology.
Key Benefits
• Promotes separation of concerns, enhancing testability and maintenance.
• Allows changing the data access implementation without altering the business logic.
// Example usage
fun main() {
val trip = Trip(id = 1, destination = "Barcelona")
non-repository repository
Repository Interface
non-repository
repository
Remote Persistence:
• Supports cross-device data sync and real-time updates
• Involves storing data on remote servers or cloud services (e.g., Firebase, AWS,
Google Cloud).
• Enables data to be synced and accessed across multiple devices.
• Supports real-time updates and collaboration.
• Often uses REST APIs or cloud databases for data management.
Example of repository connecting to local and remote data source
https://developer.android.com/training/testing/ui-tests
Local Persistence:
• SharedPreferences:
• Lightweight key-value storage, ideal for simple data.
• Stored as XML files in the app’s internal storage (similar to cache storage).
• SQLite/Room:
• Relational database for structured data, supporting complex queries.
• File Storage:
• Storing files (images, documents, etc.) in internal or external storage.
Remote Persistence:
• Involves cloud storage solutions (e.g., Firebase, AWS)
• Supports cross-device data sync and real-time updates
Disadvantages: Disadvantages:
• Limited storage capacity on the device. • Requires stable network connectivity.
• Data is confined to a single device; no cross-device • Potential latency and data synchronization challenges.
synchronization. • More complex setup, including security, authentication, and
• Potential security issues if the device is compromised. handling network failures.
https://www.sqlite.org/about.html
https://www.sqlite.org/datatype3.html
https://www.unixtimestamp.com/
*Delays will incur a 30% penalty. The last delivery cannot be delayed.
That’s all