Monday, April 26, 2010

RE: [android-developers] Re: Saving ArrayList to .txt file

Seems it was a permission issue with Astro when view that directory. How can
I view the /data directory. Is there a way to use windows explorer when the
phone is connected or anything?

-----Original Message-----
From: android-developers@googlegroups.com
[mailto:android-developers@googlegroups.com] On Behalf Of Streets Of Boston
Sent: Monday, April 26, 2010 9:49 AM
To: Android Developers
Subject: [android-developers] Re: Saving ArrayList to .txt file

Maybe that's a permission issue. Astro File manager is not allowed to
look at your app's local data (data/files in its sandbox).

However, why don't you just read the contents of the text-file you
wrote? If that's successful, writing to the text-file was successful
too.

On Apr 26, 9:11 am, "Tommy" <droi...@gmail.com> wrote:
> When I try to open the /data folder in what Astro File Manager shows as
the
> top directory (/) there is only one folder called data. Once I open that
> there is nothing else in there. Do I need to add any permissions to the
> mainifest file?
>
>
>
> -----Original Message-----
> From: android-developers@googlegroups.com
>
> [mailto:android-developers@googlegroups.com] On Behalf Of Kumar Bibek
> Sent: Monday, April 26, 2010 3:33 AM
> To: Android Developers
> Subject: [android-developers] Re: Saving ArrayList to .txt file
>
> 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" <droi...@gmail.com> 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: android-developers@googlegroups.com
>
> > [mailto:android-developers@googlegroups.com] 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 <droi...@gmail.com> 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
android-developers@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > android-developers+unsubscribe@googlegroups.com
> > > 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 android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscribe@googlegroups.com
> > 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 android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscribe@googlegroups.com
> > 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group
athttp://groups.google.com/group/android-developers?hl=en- Hide quoted text
-
>
> - Show quoted text -

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment