|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.content.Context
android.content.ContextWrapper
android.test.RenamingDelegatingContext
public class RenamingDelegatingContext
This is a class which delegates to the given context, but performs database and file operations with a renamed database/file name (prefixes default names with a given prefix).
| Field Summary |
|---|
| Constructor Summary | |
|---|---|
RenamingDelegatingContext(Context context,
Context fileContext,
String filePrefix)
|
|
RenamingDelegatingContext(Context context,
String filePrefix)
|
|
| Method Summary | ||
|---|---|---|
String[] |
databaseList()
Returns an array of strings naming the private databases associated with this Context's application package. |
|
boolean |
deleteDatabase(String name)
Delete an existing private SQLiteDatabase associated with this Context's application package. |
|
boolean |
deleteFile(String name)
Delete the given private file associated with this Context's application package. |
|
String[] |
fileList()
Returns an array of strings naming the private files associated with this Context's application package. |
|
String |
getDatabasePrefix()
|
|
File |
getFileStreamPath(String name)
Returns the absolute path on the filesystem where a file created with Context.openFileOutput(java.lang.String, int) is stored. |
|
void |
makeExistingFilesAndDbsAccessible()
Makes accessible all files and databases whose names match the filePrefix that was passed to the constructor. |
|
FileInputStream |
openFileInput(String name)
Open a private file associated with this Context's application package for reading. |
|
FileOutputStream |
openFileOutput(String name,
int mode)
Open a private file associated with this Context's application package for writing. |
|
SQLiteDatabase |
openOrCreateDatabase(String name,
int mode,
SQLiteDatabase.CursorFactory factory)
Open a new private SQLiteDatabase associated with this Context's application package. |
|
static
|
providerWithRenamedContext(Class<T> contentProvider,
Context c,
String filePrefix)
|
|
static
|
providerWithRenamedContext(Class<T> contentProvider,
Context c,
String filePrefix,
boolean allowAccessToExistingFilesAndDbs)
|
|
(package private) String |
publicNameFromDiskName(String diskName)
Returns the public name (everything following the prefix) of the given diskName. |
|
(package private) boolean |
shouldDiskNameBeVisible(String diskName)
Returns if the given diskName starts with the given prefix or not. |
|
| Methods inherited from class android.content.Context |
|---|
getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RenamingDelegatingContext(Context context,
String filePrefix)
context - : the context that will be delagated.filePrefix - : a prefix with which database and file names will be
prefixed.
public RenamingDelegatingContext(Context context,
Context fileContext,
String filePrefix)
context - : the context that will be delagated.fileContext - : the context that file and db methods will be delgated tofilePrefix - : a prefix with which database and file names will be
prefixed.| Method Detail |
|---|
public static <T extends ContentProvider> T providerWithRenamedContext(Class<T> contentProvider,
Context c,
String filePrefix)
throws IllegalAccessException,
InstantiationException
IllegalAccessException
InstantiationException
public static <T extends ContentProvider> T providerWithRenamedContext(Class<T> contentProvider,
Context c,
String filePrefix,
boolean allowAccessToExistingFilesAndDbs)
throws IllegalAccessException,
InstantiationException
IllegalAccessException
InstantiationExceptionpublic void makeExistingFilesAndDbsAccessible()
boolean shouldDiskNameBeVisible(String diskName)
diskName - name of the database/file.String publicNameFromDiskName(String diskName)
diskName - name of the database/file.public String getDatabasePrefix()
public SQLiteDatabase openOrCreateDatabase(String name,
int mode,
SQLiteDatabase.CursorFactory factory)
Context
openOrCreateDatabase in class ContextWrappername - The name (unique in the application package) of the database.mode - Operating mode. Use 0 or Context.MODE_PRIVATE for the
default operation, Context.MODE_WORLD_READABLE
and Context.MODE_WORLD_WRITEABLE to control permissions.factory - An optional factory class that is called to instantiate a
cursor when query is called.
Context.MODE_PRIVATE,
Context.MODE_WORLD_READABLE,
Context.MODE_WORLD_WRITEABLE,
Context.deleteDatabase(java.lang.String)public boolean deleteDatabase(String name)
Context
deleteDatabase in class ContextWrappername - The name (unique in the application package) of the
database.
Context.openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase.CursorFactory)public String[] databaseList()
Context
databaseList in class ContextWrapperContext.openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase.CursorFactory),
Context.deleteDatabase(java.lang.String)
public FileInputStream openFileInput(String name)
throws FileNotFoundException
Context
openFileInput in class ContextWrappername - The name of the file to open; can not contain path
separators.
FileNotFoundExceptionContext.openFileOutput(java.lang.String, int),
Context.fileList(),
Context.deleteFile(java.lang.String),
FileInputStream.FileInputStream(String)
public FileOutputStream openFileOutput(String name,
int mode)
throws FileNotFoundException
Context
openFileOutput in class ContextWrappername - The name of the file to open; can not contain path
separators.mode - Operating mode. Use 0 or Context.MODE_PRIVATE for the
default operation, Context.MODE_APPEND to append to an existing file,
Context.MODE_WORLD_READABLE and Context.MODE_WORLD_WRITEABLE to control
permissions.
FileNotFoundExceptionContext.MODE_APPEND,
Context.MODE_PRIVATE,
Context.MODE_WORLD_READABLE,
Context.MODE_WORLD_WRITEABLE,
Context.openFileInput(java.lang.String),
Context.fileList(),
Context.deleteFile(java.lang.String),
FileOutputStream.FileOutputStream(String)public File getFileStreamPath(String name)
ContextContext.openFileOutput(java.lang.String, int) is stored.
getFileStreamPath in class ContextWrappername - The name of the file for which you would like to get
its path.
Context.openFileOutput(java.lang.String, int),
Context.getFilesDir(),
Context.getDir(java.lang.String, int)public boolean deleteFile(String name)
Context
deleteFile in class ContextWrappername - The name of the file to delete; can not contain path
separators.
Context.openFileInput(java.lang.String),
Context.openFileOutput(java.lang.String, int),
Context.fileList(),
File.delete()public String[] fileList()
Context
fileList in class ContextWrapperContext.openFileInput(java.lang.String),
Context.openFileOutput(java.lang.String, int),
Context.deleteFile(java.lang.String)
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||