9

My android application is saving some stats to internal storage. Each file name is in the format of "appname-currentDate"

I was wondering:

  1. When I save to internal storage, is there a specific folder assigned to my app, or are my files saved along with files from other applications in the same directory.
  2. Is there a way to know the list of files saved by my application to the internal storage

Thank you so much.

Deepak Kumar
  • 1,035
  • 10
  • 18
Snake
  • 14,228
  • 27
  • 117
  • 250

4 Answers4

21

1) Depends on which method you use to get the file handle. Normally files are stored in an application specific directory, eg. /data/data/[your.package.name]/. The files in that directory are only readable by your application.

2) Use the getFilesDir() method in your Activity to get a File handle and use the listFiles() on it to get an array of File representing all files in your application data folder.

Further reading: http://developer.android.com/guide/topics/data/data-storage.html

Sebastian
  • 368
  • 1
  • 12
4
1-When I save to internal storage, is there a specific folder assigned to my app, or are my files saved along with files from other applications in the same direcotry.

By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user).

And files are stored in /data/data/<package_name>/files directory. Particular for your application package.

2- Is there a way to know the list of files saved by my application to the internal storage.

use method getFilesDir()

Gets the absolute path to the filesystem directory where your internal files are saved.

For more information look at Android - Internal Storage

user370305
  • 108,599
  • 23
  • 164
  • 151
  • Tahnk you +1, as I was looking for the function that actually list the files which was answered in another answer.. Thank you – Snake Jun 28 '12 at 13:56
4

Your files will be saved in data/data/your.package.com this folder. your.package.com is your package name.

You can see that in ddms. If you use eclipse and run emulator or device you can see your files in eclipse -> ddms tab

enter image description here

Nirali
  • 13,571
  • 6
  • 40
  • 53
0

use this method to get array of internal files stored by application.

https://developer.android.com/reference/android/content/Context.html#fileList()

more information here. https://developer.android.com/guide/topics/data/data-storage.html#filesInternal

vikoo
  • 2,451
  • 20
  • 27