This piece of code works for me.
You shoudl search for your file in /data/data/your package name/files
Thanks and Regards
Kumar Bibek
String filename = "test"+ System.currentTimeMillis()+".txt";
ArrayList<String> report = new ArrayList<String>();
report.add("Hello");
report.add("How are you");
FileOutputStream fos;
try {
fos =
openFileOutput(filename,Context.MODE_PRIVATE);
ObjectOutputStream out = new ObjectOutputStream(fos);
out.writeObject(report);
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
On Apr 26, 11:40 am, "Tommy" <[email protected]> wrote:
> Well at this point I have tried to write just a simple "HELLO" to the text
> file. Again it goes over the code no problem but when I search the /data
> directory there are no files or folders.
>
> String filename = "Testing.txt";
> //stationname.getText().toString() + System.currentTimeMillis();
>
> FileOutputStream fos =
> openFileOutput("testing.txt",Context.MODE_PRIVATE);
> OutputStreamWriter osw = new OutputStreamWriter(fos);
> osw.write("Hello");
> osw.flush();
> osw.close();
>
> -----Original Message-----
> From: [email protected]
>
> [mailto:[email protected]] On Behalf Of Kumar Bibek
> Sent: Monday, April 26, 2010 12:33 AM
> To: Android Developers
> Subject: [android-developers] Re: Saving ArrayList to .txt file
>
> What do you mean by there's nothing oevr there? Objects written down
> on a file would not be in a readable format. So you can't just use a
> text reader to read the contents.
>
> And if you mean that the file is empty, then the process of
> serialization is what you should check first. Try with a normal Java
> program and let us know if you have any problems.
>
> Thanks and Regards,
> Kumar Bibek
>
> On Apr 26, 8:35 am, Tommy <[email protected]> wrote:
> > Hi,
>
> > I am trying to save an array list to a .txt file below is the code I
> > am using, which runs without error but when I try to go to Astro file
> > manager and browse the data folder there is nothing there.
>
> > String filename = stationname.getText().toString() +
> > System.currentTimeMillis();
>
> > FileOutputStream fos =
> openFileOutput(filename,Context.MODE_PRIVATE);
> > ObjectOutputStream out = new ObjectOutputStream(fos);
> > out.writeObject(report); //Report is the ArrayList that holds each
> of
> > my station Reports.
> > out.close();
>
> > Any advice would be greatly appreciated.
>
> > Thanks for your time,
>
> > Tommy
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group
> athttp://groups.google.com/group/android-developers?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group
> athttp://groups.google.com/group/android-developers?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group
> athttp://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en