public class RenamingDelegatingContext extends ContextWrapper
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, BACKUP_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_NOT_VISIBLE, BIND_VISIBLE, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, COUNTRY_DETECTOR, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_ROUTER_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_POLICY_SERVICE, NETWORK_STATS_SERVICE, NETWORKMANAGEMENT_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, SCHEDULING_POLICY_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, SERIAL_SERVICE, SIP_SERVICE, STATUS_BAR_SERVICE, STORAGE_SERVICE, TELEPHONY_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, THROTTLE_SERVICE, UI_MODE_SERVICE, UPDATE_LOCK_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
Constructor and Description |
---|
RenamingDelegatingContext(Context context,
Context fileContext,
String filePrefix) |
RenamingDelegatingContext(Context context,
String filePrefix) |
Modifier and Type | Method and Description |
---|---|
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.
|
File |
getCacheDir()
In order to support calls to getCacheDir(), we create a temp cache dir (inside the real
one) and return it instead.
|
File |
getDatabasePath(String name)
Returns the absolute path on the filesystem where a database created with
Context.openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase.CursorFactory) is stored. |
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.
|
SQLiteDatabase |
openOrCreateDatabase(String name,
int mode,
SQLiteDatabase.CursorFactory factory,
DatabaseErrorHandler errorHandler)
Open a new private SQLiteDatabase associated with this Context's
application package.
|
static <T extends ContentProvider> |
providerWithRenamedContext(Class<T> contentProvider,
Context c,
String filePrefix) |
static <T extends ContentProvider> |
providerWithRenamedContext(Class<T> contentProvider,
Context c,
String filePrefix,
boolean allowAccessToExistingFilesAndDbs) |
attachBaseContext, bindService, bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createDisplayContext, createPackageContext, createPackageContextAsUser, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getClassLoader, getCompatibilityInfo, getContentResolver, getDir, getExternalCacheDir, getExternalFilesDir, getFilesDir, getMainLooper, getObbDir, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSharedPrefsFile, getSystemService, getTheme, getThemeResId, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, peekWallpaper, registerReceiver, registerReceiver, registerReceiverAsUser, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivitiesAsUser, startActivity, startActivity, startActivityAsUser, startActivityAsUser, startInstrumentation, startIntentSender, startIntentSender, startService, startServiceAsUser, stopService, stopServiceAsUser, unbindService, unregisterReceiver
getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks
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.public static <T extends ContentProvider> T providerWithRenamedContext(Class<T> contentProvider, Context c, String filePrefix) throws IllegalAccessException, InstantiationException
public static <T extends ContentProvider> T providerWithRenamedContext(Class<T> contentProvider, Context c, String filePrefix, boolean allowAccessToExistingFilesAndDbs) throws IllegalAccessException, InstantiationException
public void makeExistingFilesAndDbsAccessible()
public String getDatabasePrefix()
public SQLiteDatabase openOrCreateDatabase(String name, int mode, SQLiteDatabase.CursorFactory factory)
Context
openOrCreateDatabase
in class ContextWrapper
name
- 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.
Use Context.MODE_ENABLE_WRITE_AHEAD_LOGGING
to enable write-ahead logging by default.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.MODE_ENABLE_WRITE_AHEAD_LOGGING
,
Context.deleteDatabase(java.lang.String)
public SQLiteDatabase openOrCreateDatabase(String name, int mode, SQLiteDatabase.CursorFactory factory, DatabaseErrorHandler errorHandler)
Context
Accepts input param: a concrete instance of DatabaseErrorHandler
to be
used to handle corruption when sqlite reports database corruption.
openOrCreateDatabase
in class ContextWrapper
name
- 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.
Use Context.MODE_ENABLE_WRITE_AHEAD_LOGGING
to enable write-ahead logging by default.factory
- An optional factory class that is called to instantiate a
cursor when query is called.errorHandler
- the DatabaseErrorHandler
to be used when sqlite reports database
corruption. if null, DefaultDatabaseErrorHandler
is assumed.Context.MODE_PRIVATE
,
Context.MODE_WORLD_READABLE
,
Context.MODE_WORLD_WRITEABLE
,
Context.MODE_ENABLE_WRITE_AHEAD_LOGGING
,
Context.deleteDatabase(java.lang.String)
public boolean deleteDatabase(String name)
Context
deleteDatabase
in class ContextWrapper
name
- The name (unique in the application package) of the
database.Context.openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase.CursorFactory)
public File getDatabasePath(String name)
Context
Context.openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase.CursorFactory)
is stored.getDatabasePath
in class ContextWrapper
name
- The name of the database for which you would like to get
its path.Context.openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase.CursorFactory)
public String[] databaseList()
Context
databaseList
in class ContextWrapper
Context.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 ContextWrapper
name
- The name of the file to open; can not contain path
separators.FileNotFoundException
Context.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 ContextWrapper
name
- 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.FileNotFoundException
Context.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)
Context
Context.openFileOutput(java.lang.String, int)
is stored.getFileStreamPath
in class ContextWrapper
name
- 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 ContextWrapper
name
- 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 ContextWrapper
Context.openFileInput(java.lang.String)
,
Context.openFileOutput(java.lang.String, int)
,
Context.deleteFile(java.lang.String)
public File getCacheDir()
getCacheDir
in class ContextWrapper
Context.openFileOutput(java.lang.String, int)
,
Context.getFileStreamPath(java.lang.String)
,
Context.getDir(java.lang.String, int)