-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
about datastore #2
Comments
preferences DatatStore vs Proto DataStorehttps://youtu.be/mdQjuZbLv9Y?list=PLWz5rJ2EKKc8to3Ere-ePuco69yBUmQ9C&t=288 preferences DataStore
Proto DataStore
|
SharedPreferencesの弱点SharedPreferences には、UI スレッドで呼び出しても安全に見える同期 API がありますが、これは実際にはディスク I/O オペレーションを行います。さらに、apply() は fsync() で UI スレッドをブロックします。 refshttps://developer.android.com/codelabs/android-preferences-datastore#3 |
Preferences DataStore の概要
メモ |
Proto DataStore - 概要SharedPreferences と Preferences DataStore の欠点のひとつとして、スキーマを定義したりキーへのアクセスが正しい型によるものか確認したりする方法がないということが挙げられます。Proto DataStore では、プロトコル バッファを使用してスキーマを定義することで、この問題に対処します。Proto DataStore を使用すると、格納される型が認識され、その型のみが提供されるので、キーを使用する必要がなくなります。 メモ
|
protocol-buffersの編集にはプラグインを入れる必要がある |
DataStore とは
DataStore は、SharedPreferences に代わるものとして改善された新しいデータ ストレージ ソリューションです。Kotlin のコルーチンと Flow に基づいて構築された DataStore には、次の 2 種類の実装があります。プロトコル バッファに基づく型付きオブジェクトを保存する Proto DataStore と、Key-Value ペアを保存する Preferences DataStore です。データは非同期で一貫性を持ちトランザクションとして保存されるため、SharedPreferences の欠点の一部が解消されます。
#refs
https://developer.android.com/codelabs/android-preferences-datastore#3
The text was updated successfully, but these errors were encountered: