Added in API level 1
Deprecated in API level 24

RenamingDelegatingContext


open class RenamingDelegatingContext : ContextWrapper
kotlin.Any
   ↳ android.content.Context
   ↳ android.content.ContextWrapper
   ↳ android.test.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).

Summary

Inherited constants
Public constructors
RenamingDelegatingContext(context: Context!, fileContext: Context!, filePrefix: String!)

RenamingDelegatingContext(context: Context!, filePrefix: String!)

Public methods
open Array<String!>!

Returns an array of strings naming the private databases associated with this Context's application package.

open Boolean

Delete an existing private SQLiteDatabase associated with this Context's application package.

open Boolean

Delete the given private file associated with this Context's application package.

open Array<String!>!

Returns an array of strings naming the private files associated with this Context's application package.

open File!

In order to support calls to getCacheDir(), we create a temp cache dir (inside the real one) and return it instead.

open File!

Returns the absolute path on the filesystem where a database created with #openOrCreateDatabase is stored.

open String!

open File!

Returns the absolute path on the filesystem where a file created with openFileOutput is stored.

open Unit

Makes accessible all files and databases whose names match the filePrefix that was passed to the constructor.

open FileInputStream!

Open a private file associated with this Context's application package for reading.

open FileOutputStream!
openFileOutput(name: String!, mode: Int)

Open a private file associated with this Context's application package for writing.

open SQLiteDatabase!

Open a new private SQLiteDatabase associated with this Context's application package.

open SQLiteDatabase!

Open a new private SQLiteDatabase associated with this Context's application package.

open static T
providerWithRenamedContext(contentProvider: Class<T>!, c: Context!, filePrefix: String!)

open static T
providerWithRenamedContext(contentProvider: Class<T>!, c: Context!, filePrefix: String!, allowAccessToExistingFilesAndDbs: Boolean)

Inherited functions

Public constructors

RenamingDelegatingContext

Added in API level 1
RenamingDelegatingContext(
    context: Context!,
    fileContext: Context!,
    filePrefix: String!)
Parameters
context Context!: : the context that will be delegated.
fileContext Context!: : the context that file and db methods will be delegated to
filePrefix String!: : a prefix with which database and file names will be prefixed.

RenamingDelegatingContext

Added in API level 1
RenamingDelegatingContext(
    context: Context!,
    filePrefix: String!)
Parameters
context Context!: : the context that will be delegated.
filePrefix String!: : a prefix with which database and file names will be prefixed.

Public methods

databaseList

Added in API level 1
open fun databaseList(): Array<String!>!

Deprecated: Deprecated in Java.

Returns an array of strings naming the private databases associated with this Context's application package.

Return
Array<String!>! Array of strings naming the private databases.

deleteDatabase

Added in API level 1
open fun deleteDatabase(name: String!): Boolean

Deprecated: Deprecated in Java.

Delete an existing private SQLiteDatabase associated with this Context's application package.

Parameters
name String!: The name (unique in the application package) of the database.
Return
Boolean true if the database was successfully deleted; else false.

deleteFile

Added in API level 1
open fun deleteFile(name: String!): Boolean

Deprecated: Deprecated in Java.

Delete the given private file associated with this Context's application package.

Parameters
name String!: The name of the file to delete; can not contain path separators.
Return
Boolean true if the file was successfully deleted; else false.

fileList

Added in API level 1
open fun fileList(): Array<String!>!

Deprecated: Deprecated in Java.

Returns an array of strings naming the private files associated with this Context's application package.

Return
Array<String!>! Array of strings naming the private files.

getCacheDir

Added in API level 1
open fun getCacheDir(): File!

Deprecated: Deprecated in Java.

In order to support calls to getCacheDir(), we create a temp cache dir (inside the real one) and return it instead. This code is basically getCacheDir(), except it uses the real cache dir as the parent directory and creates a test cache dir inside that.

Return
File! The path of the directory holding application cache files.

getDatabasePath

Added in API level 1
open fun getDatabasePath(name: String!): File!

Deprecated: Deprecated in Java.

Returns the absolute path on the filesystem where a database created with #openOrCreateDatabase is stored.

The returned path may change over time if the calling app is moved to an adopted storage device, so only relative paths should be persisted.

Parameters
name String!: The name of the database for which you would like to get its path.
Return
File! An absolute path to the given database.

getDatabasePrefix

Added in API level 1
open fun getDatabasePrefix(): String!

Deprecated: Deprecated in Java.

getFileStreamPath

Added in API level 1
open fun getFileStreamPath(name: String!): File!

Deprecated: Deprecated in Java.

Returns the absolute path on the filesystem where a file created with openFileOutput is stored.

The returned path may change over time if the calling app is moved to an adopted storage device, so only relative paths should be persisted.

Parameters
name String!: The name of the file for which you would like to get its path.
Return
File! An absolute path to the given file.

makeExistingFilesAndDbsAccessible

Added in API level 1
open fun makeExistingFilesAndDbsAccessible(): Unit

Deprecated: Deprecated in Java.

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.

openFileInput

Added in API level 1
open fun openFileInput(name: String!): FileInputStream!

Deprecated: Deprecated in Java.

Open a private file associated with this Context's application package for reading.

Parameters
name String!: The name of the file to open; can not contain path separators.
Return
FileInputStream! The resulting FileInputStream.

openFileOutput

Added in API level 1
open fun openFileOutput(
    name: String!,
    mode: Int
): FileOutputStream!

Deprecated: Deprecated in Java.

Open a private file associated with this Context's application package for writing. Creates the file if it doesn't already exist.

No additional permissions are required for the calling app to read or write the returned file.

Parameters
name String!: The name of the file to open; can not contain path separators.
mode Int: Operating mode.
Value is either 0 or a combination of the following:
Return
FileOutputStream! The resulting FileOutputStream.

openOrCreateDatabase

Added in API level 1
open fun openOrCreateDatabase(
    name: String!,
    mode: Int,
    factory: SQLiteDatabase.CursorFactory!
): SQLiteDatabase!

Deprecated: Deprecated in Java.

Open a new private SQLiteDatabase associated with this Context's application package. Create the database file if it doesn't exist.

Parameters
name String!: The name (unique in the application package) of the database.
mode Int: Operating mode.
Value is either 0 or a combination of the following:
factory SQLiteDatabase.CursorFactory!: An optional factory class that is called to instantiate a cursor when query is called.
Return
SQLiteDatabase! The contents of a newly created database with the given name.
Exceptions
android.database.sqlite.SQLiteException if the database file could not be opened.

openOrCreateDatabase

Added in API level 11
Deprecated in API level 24
open fun openOrCreateDatabase(
    name: String!,
    mode: Int,
    factory: SQLiteDatabase.CursorFactory!,
    errorHandler: DatabaseErrorHandler?
): SQLiteDatabase!

Deprecated: Deprecated in Java.

Open a new private SQLiteDatabase associated with this Context's application package. Creates the database file if it doesn't exist.

Accepts input param: a concrete instance of DatabaseErrorHandler to be used to handle corruption when sqlite reports database corruption.

Parameters
name String!: The name (unique in the application package) of the database.
mode Int: Operating mode.
Value is either 0 or a combination of the following:
factory SQLiteDatabase.CursorFactory!: An optional factory class that is called to instantiate a cursor when query is called.
errorHandler DatabaseErrorHandler?: This value may be null.
Return
SQLiteDatabase! The contents of a newly created database with the given name.
Exceptions
android.database.sqlite.SQLiteException if the database file could not be opened.

providerWithRenamedContext

Added in API level 1
open static fun <T : ContentProvider!> providerWithRenamedContext(
    contentProvider: Class<T>!,
    c: Context!,
    filePrefix: String!
): T

Deprecated: Deprecated in Java.

providerWithRenamedContext

Added in API level 1
open static fun <T : ContentProvider!> providerWithRenamedContext(
    contentProvider: Class<T>!,
    c: Context!,
    filePrefix: String!,
    allowAccessToExistingFilesAndDbs: Boolean
): T

Deprecated: Deprecated in Java.