Câu hỏi phỏng vấn Android
Câu hỏi

How to persist data in an Android app?

Câu trả lời

Here is how to persist data in an Android app:

Shared Preferences

Shared Preferences is a simple key-value store for storing small amounts of primitive data. It's good for storing user settings, preferences, etc. You can save and retrieve data using the SharedPreferences API.

Internal Storage

You can save files directly on the device's internal storage. Files saved here are private to your app and not accessible to other apps or the user unless the device is rooted. Use the openFileInput() and openFileOutput() methods to read and write files.

External Storage

You can save files on the device's external storage (SD card). Files saved here are accessible to the user and other apps. Use the getExternalFilesDir() method to get a directory for saving files. Make sure to request the WRITE_EXTERNAL_STORAGE permission.

SQLite Database

SQLite is a lightweight, serverless, transactional SQL database engine. It's good for storing structured data. You can create a SQLite database using the SQLiteOpenHelper class. SQLite databases are stored in the app's private internal storage.

Room Database

Room is an abstraction layer over SQLite t...

junior

junior

Gợi ý câu hỏi phỏng vấn

expert

Explain reasons why not to use getApplicationContext() ?

expert

When would you use AIDL?

junior

Explain activity lifecycle

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào