You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The downloader module provides functionality to download the latest store and policies databases from GitHub releases. It includes methods to download databases for multiple languages.
The DAO (Data Access Object) module provides a clean interface for database operations, abstracting away direct SQL queries. It includes DAOs for accessing application data and version information, as well as utility classes for working with the data.
-**ApplicationsDao**: Provides methods for loading and searching applications in the database
419
+
-**VersionDao**: Handles database version management operations
420
+
-**AppInfoWithExtras**: A data class that extends the GooglePlayApplicationInfo model with additional information
421
+
422
+
#### Usage Example
423
+
424
+
```kotlin
425
+
// Load applications from the database
426
+
val applications =ApplicationsDao.loadApplicationsFromDatabase(
427
+
database = database,
428
+
deviceLanguage ="en",
429
+
creator = { id, categoryLocalizedName, appInfo ->
430
+
AppInfoWithExtras(
431
+
id = id,
432
+
categoryLocalizedName = categoryLocalizedName,
433
+
app = appInfo
434
+
)
435
+
}
436
+
)
437
+
438
+
// Search for applications in the database
439
+
val searchResults =ApplicationsDao.searchApplicationsInDatabase(
440
+
database = database,
441
+
query ="calculator",
442
+
deviceLanguage ="en",
443
+
creator = { id, categoryLocalizedName, appInfo ->
444
+
AppInfoWithExtras(
445
+
id = id,
446
+
categoryLocalizedName = categoryLocalizedName,
447
+
app = appInfo
448
+
)
449
+
}
450
+
)
451
+
452
+
// Get the current database version
453
+
val currentVersion =VersionDao.getCurrentVersion(database)
454
+
455
+
// Update the database version
456
+
val updateSuccess =VersionDao.updateVersion(database, "NEWVERSION")
457
+
```
458
+
459
+
#### Note on Sample Code
460
+
461
+
For a simplified overview of how to use the database, please consult the example in the `sample` directory. The sample demonstrates basic database operations including downloading, querying, and displaying data.
462
+
463
+
> ⚠️ **Important Warning**: The sample code uses `runBlocking` for database downloads, which is **prohibited** in production code. This is only done for demonstration purposes. In real applications, always use proper coroutine scopes and avoid blocking the main thread.
464
+
465
+
The DAO module is actively evolving to satisfy more needs and use cases. Contributions and pull requests are welcome to enhance its functionality and performance.
0 commit comments