Android persistence alternative to SQLite

前端 未结 7 1591
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-19 20:52

Is there any other alternative to SQLite in Android for persisting data in the phone? I am looking something like iOS coredata or something simpler like a key-value store. If we

7条回答
  •  情书的邮戳
    2021-02-19 21:29

    There are three recommended methods to store data of your Android application ( according to Android docs).

    1. If you need to save settings, configurations, user credentials You could use SharedPreferences. Pros: The data saved in SharedPreferences are comparably better than static global variable. Because it is thread safe, data will not go away even after killing the app.

    2. If you need to save big data ( e.g. accelerometer data, gps data), which is frequent, you could use SQLite database.

    3. However if you just store big data but process them rarely, it would be better to save to a file. But make sure to cache data and save/append to a file at once ( Because I/O operations are CPU intensive and drains more power).

提交回复
热议问题