0

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?

1
  • 1
    Firebase has 18 products. Which one are you asking about? Commented Jun 29, 2020 at 18:02

2 Answers 2

1

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"
}

https://developer.android.com/topic/libraries/architecture/room?gclid=EAIaIQobChMIhM-Qi8en6gIVCZ2zCh3PMQSNEAAYASAAEgIUP_D_BwE&gclsrc=aw.ds

You only need to save the json

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.