react-native-fs icon indicating copy to clipboard operation
react-native-fs copied to clipboard

Unable to write file?

Open isaaclem opened this issue 8 years ago • 5 comments

const path = RNFS.DocumentDirectoryPath + '/test.txt';
Alert.alert(path);

RNFS.writeFile(path, 'yoyo', 'utf8').then((success) => {
  // Alert.alert('DEBUG::done!');
 });

If I use RNFS.DocumentDirectoryPath, it gives me a url /data/user/0/com.manager/files/test.txt.

But from my android device's internal storage, the path appears to be

My Files > Android > data > com.manager

I've tried the following too but getting file not found error:

const path = '/data/com.manager/files/test.txt';

isaaclem avatar Sep 19 '18 04:09 isaaclem

After some studies seems like data/user/0/com.manager... is a valid path which needed root access in order to view the file.

isaaclem avatar Sep 19 '18 05:09 isaaclem

how did you solved this @isaaclem ? I also have issues because of not having root rights.. could you give me a piece of demo code?

cristianonescu avatar Oct 08 '18 15:10 cristianonescu

@cristianonescu

you can read the files in your device as so

adb shell
run-as com.your.packagename 
cp /data/data/com.your.packagename/

adamnator92 avatar Oct 12 '18 10:10 adamnator92

How did you solved it? I am also facing same issue.

rashmimhatre100 avatar Apr 12 '19 06:04 rashmimhatre100

I am also facing the same issue . Is it solved?

vipin-developer avatar Jul 04 '19 16:07 vipin-developer