Methods Summary |
---|
public java.lang.String[] | databaseList()
return mDatabaseNames.toArray(new String[]{});
|
public boolean | deleteDatabase(java.lang.String name)
if (mDatabaseNames.contains(name)) {
mDatabaseNames.remove(name);
return mFileContext.deleteDatabase(renamedFileName(name));
} else {
return false;
}
|
public boolean | deleteFile(java.lang.String name)
if (mFileNames.contains(name)) {
mFileNames.remove(name);
return mFileContext.deleteFile(renamedFileName(name));
} else {
return false;
}
|
public java.lang.String[] | fileList()
return mFileNames.toArray(new String[]{});
|
public java.lang.String | getDatabasePrefix()
return mFilePrefix;
|
public java.io.File | getFileStreamPath(java.lang.String name)
return mFileContext.getFileStreamPath(renamedFileName(name));
|
public void | makeExistingFilesAndDbsAccessible()Makes accessible all files and databases whose names match the filePrefix that was passed to
the constructor. Normally only files and databases that were created through this context are
accessible.
String[] databaseList = mFileContext.databaseList();
for (String diskName : databaseList) {
if (shouldDiskNameBeVisible(diskName)) {
mDatabaseNames.add(publicNameFromDiskName(diskName));
}
}
String[] fileList = mFileContext.fileList();
for (String diskName : fileList) {
if (shouldDiskNameBeVisible(diskName)) {
mFileNames.add(publicNameFromDiskName(diskName));
}
}
|
public java.io.FileInputStream | openFileInput(java.lang.String name)
final String internalName = renamedFileName(name);
if (mFileNames.contains(name)) {
return mFileContext.openFileInput(internalName);
} else {
throw new FileNotFoundException(internalName);
}
|
public java.io.FileOutputStream | openFileOutput(java.lang.String name, int mode)
mFileNames.add(name);
return mFileContext.openFileOutput(renamedFileName(name), mode);
|
public android.database.sqlite.SQLiteDatabase | openOrCreateDatabase(java.lang.String name, int mode, SQLiteDatabase.CursorFactory factory)
final String internalName = renamedFileName(name);
if (!mDatabaseNames.contains(name)) {
mDatabaseNames.add(name);
mFileContext.deleteDatabase(internalName);
}
return mFileContext.openOrCreateDatabase(internalName, mode, factory);
|
public static T | providerWithRenamedContext(java.lang.Class contentProvider, android.content.Context c, java.lang.String filePrefix)
return providerWithRenamedContext(contentProvider, c, filePrefix, false);
|
public static T | providerWithRenamedContext(java.lang.Class contentProvider, android.content.Context c, java.lang.String filePrefix, boolean allowAccessToExistingFilesAndDbs)
Class<T> mProviderClass = contentProvider;
T mProvider = mProviderClass.newInstance();
RenamingDelegatingContext mContext = new RenamingDelegatingContext(c, filePrefix);
if (allowAccessToExistingFilesAndDbs) {
mContext.makeExistingFilesAndDbsAccessible();
}
mProvider.attachInfo(mContext, null);
return mProvider;
|
java.lang.String | publicNameFromDiskName(java.lang.String diskName)Returns the public name (everything following the prefix) of the given diskName.
if (!shouldDiskNameBeVisible(diskName)) {
throw new IllegalArgumentException("disk file should not be visible: " + diskName);
}
return diskName.substring(mFilePrefix.length(), diskName.length());
|
private java.lang.String | renamedFileName(java.lang.String name)
return mFilePrefix + name;
|
boolean | shouldDiskNameBeVisible(java.lang.String diskName)Returns if the given diskName starts with the given prefix or not.
return diskName.startsWith(mFilePrefix);
|