언어/Android

[Android] 응용프로그램 디렉터리 검색

정현석 2010. 2. 18. 14:56
안드로이드 응용프로그램 자료는 안드로이드 파일 시스템의 아래와 같이 디렉터리에 저장된다.

/data/data/<응용프로그램 패키지 이름>/

이 디렉터리 안에 DB, 선호설정, 원본 파일들을 위한 하위 디렉터리들이 필요에 따라 생성된다. 코드에서 파일을 다루려면 우선 Application의 Context 객체를 얻어야 한다.

android.content.Context


abstract Context createPackageContext(String packageName, int flags)
Return a new Context object for the given application name.
abstract String[] databaseList()
Returns an array of strings naming the private databases associated with this Context's application package.
abstract boolean deleteDatabase(String name)
Delete an existing private SQLiteDatabase associated with this Context's application package.
abstract boolean deleteFile(String name)
Delete the given private file associated with this Context's application package.
abstract String[] fileList()
Returns an array of strings naming the private files associated with this Context's application package.
abstract Context getApplicationContext()
Return the context of the single, global Application object of the current process.
abstract ApplicationInfo getApplicationInfo()
Return the full application info for this context's package.
abstract File getCacheDir()
Returns the absolute path to the application specific cache directory on the filesystem.
abstract File getDatabasePath(String name)
Returns the absolute path on the filesystem where a database created with openOrCreateDatabase(String, int, SQLiteDatabase.CursorFactory) is stored.
abstract File getDir(String name, int mode)
Retrieve, creating if needed, a new directory in which the application can place its own custom data files.
abstract File getFileStreamPath(String name)
Returns the absolute path on the filesystem where a file created with openFileOutput(String, int) is stored.
abstract File getFilesDir()
Returns the absolute path to the directory on the filesystem where files created with openFileOutput(String, int) are stored.
final CharSequence getText(int resId)
Return a localized, styled CharSequence from the application's package's default string table.
abstract FileInputStream openFileInput(String name)
Open a private file associated with this Context's application package for reading.
abstract FileOutputStream openFileOutput(String name, int mode)
Open a private file associated with this Context's application package for writing.
abstract SQLiteDatabase openOrCreateDatabase(String name, int mode, SQLiteDatabase.CursorFactory factory)
Open a new private SQLiteDatabase associated with this Context's application package.
int MODE_APPEND File creation mode: for use with openFileOutput(String, int), if the file already exists then write data to the end of the existing file instead of erasing it.
int MODE_PRIVATE File creation mode: the default mode, where the created file can only be accessed by the calling application (or all applications sharing the same user ID).
int MODE_WORLD_READABLE File creation mode: allow all other applications to have read access to the created file.
int MODE_WORLD_WRITEABLE File creation mode: allow all other applications to have write access to the created file.