Re: [android-beginners] application space files access.

2010-06-25 Thread TreKing
On Mon, Jun 21, 2010 at 7:27 AM, changdeo changdeojad...@gmail.com wrote:

 Can anybody please help me to create a file on application space and
 tell a way to read it.


There are various log-reading apps available for exactly this reason. You
can just have your users install one of those apps and send you the logs via
email.


 I am doing this

 String fileName = Environment.getExternalStorageDirectory()+/
 WFLog.txt;


That's for writing to the SD card, not application space.

Also, don't randomly append strings together to form file paths. Use the
various File constructors and functions to form a complete, valid File
object.

Alternative I thought was to create log file on sdcard but I can not delete
 it when application gets uninstalled. This also can be helpful if anybody
 knows how to delete sdcard files created by applicationon removal(unistall) of
 application.


I believe this is in the works, and maybe available in Froyo, I can't
remember.

-
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] application space files access.

2010-06-21 Thread changdeo
Hi,
 I want to create a log file for my application in application space,
so that user can review what went wrong. But We can not access files
created in application space(access in the sense that we can not pull
it to desktop , or can not view on phone using some editor). Can
anybody please help me to create a file on application space and tell
a way to read it.

I am doing this

String fileName = Environment.getExternalStorageDirectory()+/
WFLog.txt;
FileOutputStream fout = new FileOutputStream(fileName);

I have also tried using
openOutputStream with permission WORLD_READABLE.

Alternative I thought was to create log file on sdcard but I can not
delete it when application gets uninstalled. This also can be helpful
if anybody knows how to delete sdcard files created by application on
removal(unistall) of application.

ThanksRegards
Changdeo Jadhav

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


Re: [android-beginners] application space files access.

2010-06-21 Thread Mark Murphy
On Mon, Jun 21, 2010 at 8:27 AM, changdeo changdeojad...@gmail.com wrote:
  I want to create a log file for my application in application space,
 so that user can review what went wrong. But We can not access files
 created in application space(access in the sense that we can not pull
 it to desktop , or can not view on phone using some editor). Can
 anybody please help me to create a file on application space and tell
 a way to read it.

If you want people to manipulate the file independently of your
application, put it on the SD card.

 I am doing this

 String fileName = Environment.getExternalStorageDirectory()+/
 WFLog.txt;
 FileOutputStream fout = new FileOutputStream(fileName);

If you have the WRITE_EXTERNAL_STORAGE permission, this should work to
write a file to the SD card.

 I have also tried using
 openOutputStream with permission WORLD_READABLE.

This will not help much, as no apps will readily be able to browse to that file.

 Alternative I thought was to create log file on sdcard but I can not
 delete it when application gets uninstalled.

On Android 2.2, you can use getExternalFilesDir() (available on
Activity and other subclasses of Context) to get access to a directory
on the SD card that will be removed automatically when the application
is uninstalled.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en