Saving data in a file

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Saving data in a file

Postby williamzanelli » Wed Sep 09, 2009 2:59 pm

Hi guys

I want to save some data in a file,

I'm looking at this tutorial, [http://www.anddev.org/write_to_and_read_from_a_file-t3173.html]

My question is, If the file already exists, by creating a new one of the same name, would that overwrite the existing one?

Thanks for your thoughts
Will
williamzanelli
Experienced Developer
Experienced Developer
 
Posts: 63
Joined: Mon Jan 05, 2009 2:37 am
Location: UK

Top

Re: Saving data in a file

Postby saamyandroid » Wed Sep 09, 2009 8:33 pm

i Too have same Doubt . can any one reply?
saamyandroid
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Wed Sep 09, 2009 8:17 pm
Location: INDIA

Postby azraeal » Thu Sep 10, 2009 12:27 am

The behavior depends on how you opened the file in question. By default, you would overwrite the old file. If you want to append to the file, you'd need to open the file with the append flag.

Looking at your link, the change would be changing
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. openFileOutput("settings.dat",MODE_PRIVATE);
Parsed in 0.046 seconds, using GeSHi 1.0.8.4

to
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. openFileOutput("settings.dat",MODE_APPEND);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


Full documentation here: http://developer.android.com/reference/ ... ing,%20int).
azraeal
Experienced Developer
Experienced Developer
 
Posts: 71
Joined: Fri Sep 04, 2009 6:34 pm
Location: California

Postby saamyandroid » Thu Sep 10, 2009 9:31 am

thanks for ur reply
saamyandroid
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Wed Sep 09, 2009 8:17 pm
Location: INDIA

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google Feedfetcher and 4 guests