Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
338 views
in Technique[技术] by (71.8m points)

android - List of files of saved to the internal storage

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...