data
3
总安装量
2
周安装量
#59386
全站排名
安装命令
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-android --skill data
Agent 安装分布
claude-code
2
mcpjam
1
moltbot
1
windsurf
1
zencoder
1
Skill 文档
Data Persistence Skill
Quick Start
Room Entity & DAO
@Entity
data class User(@PrimaryKey val id: Int, val name: String)
@Dao
interface UserDao {
@Query("SELECT * FROM User")
suspend fun getAllUsers(): List<User>
@Insert
suspend fun insert(user: User)
}
EncryptedSharedPreferences
val prefs = EncryptedSharedPreferences.create(context, "secret",
MasterKey.Builder(context).setKeyScheme(AES256_GCM).build(),
AES256_SIV, AES256_GCM)
prefs.edit { putString("token", value) }
DataStore
val dataStore = context.createDataStore("settings")
val preferences = dataStore.data.map { it[KEY] ?: "" }
Key Concepts
Room Advantages
- Type-safe queries
- Compile-time checks
- Suspend/Flow support
- Migration management
SharedPreferences
- Simple key-value store
- Use Encrypted version for sensitive data
- Limited to small data
DataStore
- Modern SharedPreferences
- Coroutine-native
- Type-safe
- ACID transactions
Best Practices
â Use Room for complex data â Encrypt sensitive data â Implement proper migrations â Handle database errors â Test database operations