On Jul 26, 2011, at 4:08 PM, Tim Kelly wrote:
> Ok, this might to oblivious, but I cannot seem to be able to figure it out.  
> My application writes information to a file, so I want to view the contents 
> of that file.  So how do you view files in the emulator??

The app that created the file can view the file. By default, only the creating 
app can read files in the app's directory.

If you're on the emulator, `adb shell` has root access, and thus can view 
~everything, so you could use `adb shell cat /path/to/file` to view the 
contents of a file. This won't work on a non-jailbroken device, though.

If you want other apps to view the file, or you want to be able to view the 
file on non-jailbroken hardware, you need to place it into a directory that 
other apps can read. You can do this either via:

 1. Context.GetDir(string,FileCreationMode)[0] with 
FileCreationMode.WorldReadable to allow others to read the directory. This 
should create a directory under /data/data/@PACKAGE_NAME@/files, and if other 
apps (and/or you) know the full path you should be able to read the directory 
contents.

 2. Placing your file into an "external" directory, via 
Context.GetExternalFilesDir()[1] or Environment.ExternalStorageDirectory [2].

 - Jon

[0] 
http://docs.mono-android.net/Android.Content.Context.GetDir%20(string,%20Android.Content.FileCreationMode)

[1] 
http://docs.mono-android.net/Android.Content.Context.GetExternalFilesDir%20(string)

[2] http://docs.mono-android.net/Android.OS.Environment.ExternalStorageDirectory
_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to