# Quản lý Dữ liệu Android (Android) > SharedPreferences, DataStore, File I/O, Internal/External Storage, Scoped Storage - 29 câu hỏi phỏng vấn - Junior - [Câu hỏi phỏng vấn: Android](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van.md) ## 1. SharedPreferences trong Android là gì? **Câu trả lời** SharedPreferences là một hệ thống lưu trữ key-value đơn giản để lưu dữ liệu nguyên thủy (int, boolean, float, long, String, Set). Dữ liệu được duy trì giữa các phiên ứng dụng và khởi động lại. Lý tưởng cho tùy chọn người dùng, cài đặt, dữ liệu nhỏ. API đơn giản: getSharedPreferences(), edit(), putString(), apply()/commit(). ## 2. Làm thế nào để lưu một giá trị vào SharedPreferences? **Câu trả lời** Lấy instance: val prefs = context.getSharedPreferences('name', Context.MODE_PRIVATE). Chỉnh sửa: val editor = prefs.edit(); editor.putString('key', 'value'); editor.apply() (bất đồng bộ) hoặc editor.commit() (đồng bộ). Cũng có thể chain: prefs.edit().putString('key', 'value').apply(). ## 3. Sự khác biệt giữa apply() và commit() là gì? **Câu trả lời** apply() là bất đồng bộ (ghi ở chế độ nền, không chặn UI thread), không trả về gì, được khuyến nghị trong hầu hết các trường hợp. commit() là đồng bộ (chặn cho đến khi ghi xong), trả về boolean (true nếu thành công), hữu ích nếu cần xác minh thành công ngay lập tức. apply() có hiệu năng tốt hơn cho UI. ## Còn 26 câu hỏi nữa - Làm thế nào để đọc một giá trị từ SharedPreferences? - Jetpack DataStore là gì? Đăng ký miễn phí: https://sharpskill.dev/vi/login ## Các chủ đề phỏng vấn Android khác - [Nền tảng Android](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-fundamentals.md): 24 câu hỏi, Junior - [UI và Tài nguyên Android](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-ui-and-resources.md): 30 câu hỏi, Junior - [Vòng đời Android](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-lifecycle.md): 30 câu hỏi, Junior - [Điều hướng Android](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-navigation.md): 26 câu hỏi, Junior - [Networking Android](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-networking.md): 29 câu hỏi, Junior - [Kiểm thử Android](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-testing.md): 28 câu hỏi, Junior - [Android Gradle](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-gradle.md): 26 câu hỏi, Junior - [Kiến thức cơ bản về ngôn ngữ Kotlin cho Android](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-kotlin-language-essentials.md): 24 câu hỏi, Junior - [Room Database](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-room-database.md): 25 câu hỏi, Mid-Level - [Xử lý nền](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-background-work.md): 18 câu hỏi, Mid-Level - [Jetpack Compose](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-compose.md): 28 câu hỏi, Mid-Level - [Quyền và Tính năng Thiết bị](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-permissions-and-device.md): 21 câu hỏi, Mid-Level - [Firebase cho Android](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-firebase.md): 23 câu hỏi, Mid-Level - [Android MVVM Architecture](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-mvvm-architecture.md): 18 câu hỏi, Mid-Level - [Mạng Android Nâng Cao](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-networking-advanced.md): 13 câu hỏi, Mid-Level - [Collections và Toán tử Kotlin](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-kotlin-collections-operators.md): 20 câu hỏi, Mid-Level - [Kotlin Coroutines và Flow](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-kotlin-coroutines-flow.md): 20 câu hỏi, Mid-Level - [Dependency Injection trong Android](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-dependency-injection.md): 15 câu hỏi, Mid-Level - [Android MVI Architecture](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-mvi-architecture.md): 17 câu hỏi, Mid-Level - [Android Clean Architecture](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-clean-architecture.md): 21 câu hỏi, Senior - [Android Compose Nâng cao](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-compose-advanced.md): 17 câu hỏi, Senior - [Android Performance and Monitoring](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-performance-monitoring.md): 13 câu hỏi, Senior - [Android Security and Privacy](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-security-privacy.md): 18 câu hỏi, Senior - [Android CI/CD and Release](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-cicd-release.md): 15 câu hỏi, Senior - [Android UX and Form Factors](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-ux-form-factors.md): 18 câu hỏi, Senior - [Android Testing Advanced](https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-testing-advanced.md): 18 câu hỏi, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/vi/technologies/android/cau-hoi-phong-van/android-data-management