-3

Following are the requirements for creating a file in my Android application

1.File will be created when the application is launched at first time and write 0 to the file

2.whenever the application is opened, first read from the file and then based on that value a new value will be written to the file.

please help me.

Gopi
  • 689
  • 1
  • 8
  • 17
  • i used openFileOutput() to create file but this recreates my file each time when I start the application overriding the existing contents. – Gopi Oct 23 '13 at 10:12

1 Answers1

0

I suggest you read this ...

From what you're asking, I think Shared Preferences are the way to go, since it looks like you just want to store an int value.

2Dee
  • 8,609
  • 7
  • 42
  • 53
  • of course I can do that but I want to know how to create a file when the application is launched at first time – Gopi Oct 23 '13 at 10:19
  • read the first link I provided until the end, I doubt you had time to read it all in 7 minutes ... If you really want to save a file, it explains you can do that "Using the Internal Storage" and getCacheDir(). At application startup, you just have to check if the file exists, if not, create it, and if it does, read it, modify the value in it, and save it again ... – 2Dee Oct 23 '13 at 10:27