that delight users • Businesses that are profitable • Professionals with successful careers KMP's impact: • Smooth native interoperability • Reduced time to market • Transferable skills
use SQLite databases in applications, by using its annotation APIs that generate code. Link: h tt ps://developer.android.com/training/data-storage/room
= 1 ) abstract class MusicDatabase : RoomDatabase() { abstract fun musicDao(): MusicDao } @Entity data class Song( @PrimaryKey val songId: Long, ) @Entity data class Album( @PrimaryKey val albumId: Long ) @Entity data class Artist( @PrimaryKey val artistId: Long )
XTypeName: Represents a type name in Java and Kotlin's type system. • XFunSpec: Represents a Java/Kotlin function. • XCodeBlock: Represents a snippet of JPL/Kotlin code, supporting placeholders for values, names, types, and members. … and more!
val _stringBuilder: StringBuilder = StringBuilder() _stringBuilder.append("SELECT * FROM MyEntity WHERE string IN (") val _inputSize: Int = arg.size appendPlaceholders(_stringBuilder, _inputSize) _stringBuilder.append(")") val _sql: String = _stringBuilder.toString() return performBlocking(__db, true, false) { _connection -> val _stmt: SQLiteStatement = _connection.prepare(_sql) try { var _argIndex: Int = 1 for (_item: String in arg) { _stmt.bindText(_argIndex, _item) _argIndex++ } ... (Generated Code)
to cross-compile SQLite • C-interop for SQLite access within Kotlin code • Development of bundled and framework SQLite drivers Link: h tt ps://developer.android.com/kotlin/multipla tf orm/sqlite
FileLock actual constructor(filename: String) { // src/androidJvmMain/.../FileLock.androidJvm.kt import java.io.* import java.nio.channels.* internal actual class FileLock actual constructor(filename: String) { Strategy
fun equals(other: Any?) = equalsCommon(other) actual override fun hashCode() = hashCodeCommon() } // src/androidMain/.../TableInfo.android.kt actual class TableInfo { actual override fun equals(other: Any?) = equalsCommon(other) actual override fun hashCode() = hashCodeCommon() companion object { fun read(database: SupportSQLiteDatabase) { ... } } } Strategy
in room Move JPL sources to be Kotlin sources Add cross-platform SQLite support Migrate sources to use cross-platform SQLite drivers Generate cross-platform compatible code Add Kotlin code generation
release marks a significant milestone in Room’s KMP journey, with non-Android platforms currently nearing full feature parity. • Expanded Platform Support Future development plans for Room include expansion to Web via SQLite WASM. • Google's Official Investment in KMP Room's adoption of KMP aligns with Google’s continued investment in KMP, contributing to the growth and success of the ecosystem.