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!, filePrefix: String!)

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

Public methods
open Array<String!>!

open Boolean

open Boolean

open Array<String!>!

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!

open String!

open File!

open Unit

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

open FileInputStream!

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

open SQLiteDatabase!

open SQLiteDatabase!

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!,
    filePrefix: String!)
Parameters
context Context!: : the context that will be delegated.
filePrefix String!: : a prefix with which database and file names will be prefixed.

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.

Public methods

databaseList

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

Deprecated: Deprecated in Java.

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.

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.

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.

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.

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.

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.

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.

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 android.content.Context#MODE_PRIVATE, android.content.Context#MODE_WORLD_READABLE, android.content.Context#MODE_WORLD_WRITEABLE, and android.content.Context#MODE_APPEND
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.

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 android.content.Context#MODE_PRIVATE, android.content.Context#MODE_WORLD_READABLE, android.content.Context#MODE_WORLD_WRITEABLE, android.content.Context#MODE_ENABLE_WRITE_AHEAD_LOGGING, and android.content.Context#MODE_NO_LOCALIZED_COLLATORS
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.

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 android.content.Context#MODE_PRIVATE, android.content.Context#MODE_WORLD_READABLE, android.content.Context#MODE_WORLD_WRITEABLE, android.content.Context#MODE_ENABLE_WRITE_AHEAD_LOGGING, and android.content.Context#MODE_NO_LOCALIZED_COLLATORS
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.