Reputation: 1003
I am wondering if I cache all the data from firebase and after turn off the wifi it will work as well as was before. But if I turn off the wifi and restart the phone and enter the program without wifi, will it work?
Upvotes: 0
Views: 48
Reputation: 1371
If you use room or localstorage to save data, it is functioned
Example
val sharedPref = activity?.getPreferences(Context.MODE_PRIVATE) ?: return
with (sharedPref.edit()) {
putInt(getString(R.string.saved_high_score_key), newHighScore)
commit()
}
Link del code
https://developer.android.com/training/data-storage/shared-preferences
Room
dependencies {
def room_version = "2.2.5"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version" // For Kotlin use kapt instead of annotationProcessor
// optional - Kotlin Extensions and Coroutines support for Room
implementation "androidx.room:room-ktx:$room_version"
// optional - RxJava support for Room
implementation "androidx.room:room-rxjava2:$room_version"
// optional - Guava support for Room, including Optional and ListenableFuture
implementation "androidx.room:room-guava:$room_version"
// Test helpers
testImplementation "androidx.room:room-testing:$room_version"
}
You only need to save the json
Upvotes: 1
Reputation: 317372
Yes, you can still query the data, as it's been persisted on the device's storage. This should be pretty easy for you to try for yourself.
Upvotes: 0