Thank you Jack,
It works.
On Aug 11, 5:16 pm, Jack Ha jack...@t-mobile.com wrote:
Context.openFileOutput() opens a private file associated with this
Context's application package for writing and the name of the file to
open can not contain path separators.
Try this:
try {
File root = Environment.getExternalStorageDirectory();
if (root.canWrite()){
File f = new File(root, test.txt);
FileWriter fw = new FileWriter(f);
BufferedWriter out = new BufferedWriter(fw);
out.write(Hello world);
out.close();
}
} catch (IOException e) {
}
--
Jack Ha
Open Source Development Center
・T・ ・ ・Mobile・ stick together
The views, opinions and statements in this email are those of
the author solely in their individual capacity, and do not
necessarily represent those of T-Mobile USA, Inc.
On Aug 11, 1:57 pm, Saeed saeed.pourbagh...@gmail.com wrote:
Hi everyone,
I am trying to save data to my google phone G1. I am able to create
the text file in sdcard by using the following code in eclipse :
//++
try {
FileWriter f = new FileWriter(/sdcard/test.txt);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//+
but I am not able to save any data to the created file. I found this
code from http://www.anddev.org/working_with_files-t115.html; which
says I can write to text file by running this code.
//+++
try { // catches IOException below
final String TESTSTRING = new String(hello);
FileOutputStream fOut = openFileOutput(/sdcard/test.txt,
MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
// Write the string to the file
osw.write(TESTSTRING);
// ensure that everything is
// really written out and close
osw.flush();
osw.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
//+
I run it but I do not see any change in my file.
first, I thought my problem is permission to file. The permission
setting on my phone is:
data : drwxrwx--x
sdcard : d---rwxrwx
system : drwxr-xr-x
would you please help me in either in correcting the code or finding a
way to save data into text file (saved in sdcard or the phone) in
eclipse environment
thanks in advance
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Beginners group.
To post to this group, send email to android-beginners@googlegroups.com
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
-~--~~~~--~~--~--~---