[mono-android] Changing Folder/File permissions in MfA

Jonathan Pryor jonp at xamarin.com
Wed Oct 24 14:02:21 UTC 2012


On Oct 24, 2012, at 3:27 AM, was <skylogdev at btconnect.com> wrote:
> After some xperimentation, I found using:
> 
> $ adb shell cat /data/data/App.AppName/files/appname.db
> 
> to copy the file to the PC results in a slightly larger file that cannot be opened by the PC's sqlite database (RazorSQL),

It could be because `adb shell cat` is appending a newline to the output. `adb pull` won't do that.

> can be. So, I don't think the StreamWriter method will work as it looks like I can only use the ADB pull/push commands.

The use of StreamWriter was just to easily write text. The actual "solution" is the use of Context.OpenFileOutput(string, FileCreationMode), which does allow use of `adb pull` and `adb push` as long as you know the filename:

	$ adb push some-file.txt /data/data/Scratch.PublicFiles/files/foo.txt
	72 KB/s (2752 bytes in 0.037s) 
	$ adb shell cat /data/data/Scratch.PublicFiles/files/foo.txt
	# get updated file contents

As long as it's acceptable to "just  know the filenames" (i.e. `adb shell ls path` won't work), then using Context.OpenFileOutput() should be fine. It's only if you need to permit directory listing that you need chmod(2).

 - Jon



More information about the Monodroid mailing list