Android persistence alternative to SQLite

前端 未结 7 1645
爱一瞬间的悲伤
爱一瞬间的悲伤 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).

    0 讨论(0)
提交回复
热议问题