Android データ管理
SharedPreferences、DataStore、File I/O、Internal/External Storage、Scoped Storage
29 面接問題·
Junior
1Android の SharedPreferences とは何ですか?
1
Android の SharedPreferences とは何ですか?
回答
SharedPreferences は、プリミティブデータ(int、boolean、float、long、String、Set<String>)を保存するためのシンプルなキー値ストレージシステムです。データはアプリのセッションや再起動の間も永続化されます。ユーザー設定、設定値、小さなデータに最適です。シンプルな API: getSharedPreferences()、edit()、putString()、apply()/commit()。
2SharedPreferences に値を保存するにはどうしますか?
2
SharedPreferences に値を保存するにはどうしますか?
回答
インスタンスを取得: val prefs = context.getSharedPreferences('name', Context.MODE_PRIVATE)。編集: val editor = prefs.edit(); editor.putString('key', 'value'); editor.apply()(非同期)または editor.commit()(同期)。チェーンも可能: prefs.edit().putString('key', 'value').apply()。
3apply() と commit() の違いは何ですか?
3
apply() と commit() の違いは何ですか?
回答
apply() は非同期で(バックグラウンドで書き込み、UI スレッドをブロックしない)、何も返さず、ほとんどの場合に推奨されます。commit() は同期で(書き込みまでブロック)、boolean を返し(成功すれば true)、成功をすぐに確認する必要がある場合に役立ちます。apply() は UI のパフォーマンスが向上します。
4
SharedPreferences から値を読み取るにはどうしますか?
5
Jetpack DataStore とは何ですか?
+26 面接問題
その他のAndroid面接トピック
Android の基礎
Junior
24問Android UIとリソース
Junior
30問Androidライフサイクル
Junior
30問Android ナビゲーション
Junior
26問Android ネットワーキング
Junior
29問Android テスト
Junior
28問Android Gradle
Junior
26問Android向けKotlin言語の基礎
Junior
24問Room Database
Mid-Level
25問バックグラウンド処理
Mid-Level
18問Jetpack Compose
Mid-Level
28問パーミッションとデバイス機能
Mid-Level
21問Android向けFirebase
Mid-Level
23問Android MVVM Architecture
Mid-Level
18問Androidネットワーキング上級
Mid-Level
13問Kotlinのコレクションと演算子
Mid-Level
20問Kotlin Coroutinesとflow
Mid-Level
20問Android の依存性注入
Mid-Level
15問Android MVI Architecture
Mid-Level
17問Android Clean Architecture
Senior
21問Android Compose 上級
Senior
17問Android Performance and Monitoring
Senior
13問Android Security and Privacy
Senior
18問Android CI/CD and Release
Senior
15問Android UX and Form Factors
Senior
18問Android Testing Advanced
Senior
18問