Recall & Review
beginner
What is the purpose of the
react-native-fs library?It provides an easy way to read, write, and manage files on a device's file system in React Native apps.
Click to reveal answer
beginner
How do you read a text file asynchronously using
react-native-fs?Use
RNFS.readFile(path, 'utf8') which returns a promise with the file content as a string.Click to reveal answer
intermediate
What is the difference between
DocumentDirectoryPath and ExternalDirectoryPath in React Native file system?DocumentDirectoryPath is private app storage, backed up and sandboxed. ExternalDirectoryPath is public external storage, accessible by other apps (Android only).Click to reveal answer
beginner
Why should you handle permissions when accessing the file system on mobile devices?
Because mobile OSes restrict file access for security. You must request user permission to read/write files outside your app sandbox.
Click to reveal answer
beginner
What method would you use to check if a file exists before reading it in React Native?
Use
RNFS.exists(path) which returns a promise resolving to true if the file exists, false otherwise.Click to reveal answer
Which React Native library is commonly used for file system access?
✗ Incorrect
react-native-fs is the library designed for file system operations like reading and writing files.
What does
RNFS.readFile(path, 'utf8') return?✗ Incorrect
This method returns a promise that resolves to the file contents as a string.
Which directory path is private and sandboxed for your app?
✗ Incorrect
DocumentDirectoryPath is private app storage, safe from other apps.
Before reading a file, which method helps you check if it exists?
✗ Incorrect
RNFS.exists(path) returns true if the file exists, helping avoid errors.
Why must you request permissions for file system access on mobile?
✗ Incorrect
Mobile OSes restrict file access to protect user data, so apps must ask permission.
Explain how to read a text file in React Native using
react-native-fs.Think about asynchronous file reading with promises.
You got /4 concepts.
Describe the difference between private and external storage paths in React Native file system.
Consider where files are stored and who can access them.
You got /4 concepts.