android – Download file using react native

Question:

I have an Android app that when running it accesses a file and lists some information on the screen.

The point is that it only works if you have internet.

What I need is to download the information and save it to the device to be accessed offline.

How should I do?

Answer:

Have you tried using AsyncStorage?

To save the information:


AsyncStorage.setItem("chave", "valor");

To recover:


AsyncStorage.getItem("chave").then((value) => {
    // salvar no "this.state".
    this.setState({"chave": value});
}).done();

Hug.

Scroll to Top