Joji Thomas
Joji Thomas

Reputation: 183

How to open a text file and read the contents from it on react native?

I want to read and display the text contents from a .txt file which is saved locally to the app build with react native.

The text is huge hence i cant hard code it to the code.

Upvotes: 6

Views: 9482

Answers (1)

Burak Tokak
Burak Tokak

Reputation: 1860

I think you are using Expo,

You can use expo filesystem https://docs.expo.io/versions/latest/sdk/filesystem

Which is a native wrapper for platform specific system file management methods. You can read and change files managed in your app's domain.

For Eg:

Expo.FileSystem.readAsStringAsync(fileUri)

Upvotes: 3

Related Questions