Since: API level 19
public class

SdpFileSystem

extends Object
java.lang.Object
   ↳ com.samsung.android.knox.sdp.SdpFileSystem

Deprecated in API level 33

Class Overview

SdpFileSystem provides convenient APIs for manipulating file(s) as sensitive.

Since
API level 19
KNOX 2.6

Summary

Public Constructors
SdpFileSystem(Context c, String alias)
Deprecated in API level 33
Public Methods
File getCacheDir()
Deprecated in API level 33
File getDatabasePath(String name)
Deprecated in API level 33
File getExternalStorageDirectory()
Deprecated in API level 33
static File getExternalStorageDirectory(int userId)
Deprecated in API level 33
File getFilesDir()
Deprecated in API level 33
File getManagedProfileKnoxDir()
Deprecated in API level 33
File getUserDataDir()
Deprecated in API level 33
static File getUserDataDir(int userId, String packageName)
Deprecated in API level 33
boolean isSensitive(File f)
Deprecated in API level 33
SQLiteDatabase openOrCreateDatabase(String name, int mode, SQLiteDatabase.CursorFactory factory, DatabaseErrorHandler errorHandler)
Deprecated in API level 33
SQLiteDatabase openOrCreateDatabase(String name, int mode, SQLiteDatabase.CursorFactory factory)
Deprecated in API level 33
boolean setSensitive(File f)
Deprecated in API level 33
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public SdpFileSystem (Context c, String alias)

Since: API level 19

Deprecated in API level 33

Construct a new SdpFileSystem object with the given context and alias. This can be used to manipulate the Sdp filesystem.

Usage:

        An application developer can use this constructor to create an instance of the object.


     try {

         String alias = "sdpDemo"; // In case of default engine, alias will be null.

         SdpFileSystem sdpFileSystem = new SdpFileSystem(mContext, alias);

         File file = new File(sdpFileSystem.getFilesDir(), "file_path");

     } catch (SdpException e) {

         e.printStackTrace();

     }

 

Parameters
c Android Context. Interface to global information about an application environment.
alias SdpEngine alias. null for default engine.
Throws
SdpException thrown when SDP engine doesn't exist, license activation is required or internal error has occured.
Since
API level 19
KNOX 2.6
Multiuser Environment
User Scope

Public Methods

public File getCacheDir ()

Since: API level 19

Deprecated in API level 33

API returns application specific cache directory in the encrypted filesystem. Application specific temporary files can be stored at this location. This is the encrypted storage equivalent of Android API getCacheDir().

Usage:

        An Application Developer can use this API to get the handle of encrypted data cache directory related to the engine information passed to SdpFileSystem.


     try {

         String alias = "alias";

         SdpFileSystem sFS = new SdpFileSystem(this, alias);

         File cacheDir = sFS.getCacheDir();

     } catch (SdpException e ) {

         e.printStackTrace();

     }

 

Returns
  • An absolute path to application specific cache directory.
Since
API level 19
KNOX 2.6
Multiuser Environment
User Scope
See Also

public File getDatabasePath (String name)

Since: API level 19

Deprecated in API level 33

API returns the absolute path of the database on the encrypted filesystem, created with openOrCreateDatabase(String, int, CursorFactory) or openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler).

Usage:

        Deleting a database by checking the existance of the DatabasePath.


     File database = mContext.getDatabasePath(mDbFileName);

     if (database.exists()) {

         database.delete();

     }

     openDatabase();

 

Parameters
name Database name.
Returns
  • An absolute path to the database.
Since
API level 19
KNOX 2.6
Multiuser Environment
User Scope

public File getExternalStorageDirectory ()

Since: API level 19

Deprecated in API level 33

API returns the external storage directory root in the encrypted filesystem. The external storage is shared between all the applications and can hold relatively large data. This is the encrypted storage equivalent of Android API getExternalStorageDirectory().

Usage:

        An Application Developer can use this API to get the handle of encrypted external storage related to the engine information passed to SdpFileSystem.


     try {

         String alias = "alias";

         SdpFileSystem sFS = new SdpFileSystem(this, alias);

         File encDir = sFS.getExternalStorageDirectory();

     } catch (SdpException e ) {

         e.printStackTrace();

     }

 

Returns
  • An absolute path to the external storage directory.
Since
API level 19
KNOX 2.6
Multiuser Environment
User Scope

public static File getExternalStorageDirectory (int userId)

Since: API level 19

Deprecated in API level 33

API returns the external storage directory root in the encrypted filesystem. The external storage is shared between all the applications and can hold relatively large data. This is the encrypted storage equivalent of Android API getExternalStorageDirectory().

Usage:

        An Application Developer can use this API to get the handle of encrypted external storage path with the specific user id.


     int userId = 0;

     File encDir = SdpFileSystem.getExternalStorageDirectory(userId);

 

Parameters
userId Android user id.
Returns
  • An absolute path to the external storage directory.
Since
API level 19
KNOX 2.6
Multiuser Environment
User Scope

public File getFilesDir ()

Since: API level 19

Deprecated in API level 33

API returns application specific files directory in the encrypted filesystem. Application specific private files can be stored at this location. This is the encrypted storage equivalent of Android API getFilesDir().

Usage:

        This test starts to determine the files directory by returning the directory location to the variable "file".


     try {

         String alias = "sdpDemo"; // In case of default engine, alias will be null.

         SdpFileSystem sdpFileSystem = new SdpFileSystem(mContext, alias);

         File file = new File(sdpFileSystem.getFilesDir(), "file_path");

         boolean result = false;

         if(!sdpFileSystem.isSensitive(file)) {

             result = sdpFileSystem.setSensitive(file)

         }

     } catch (SdpException e) {

         e.printStackTrace();

     }

 

Returns
  • An absolute path to the application specific private files directory.
Since
API level 19
KNOX 2.6
Multiuser Environment
User Scope

public File getManagedProfileKnoxDir ()

Since: API level 19

Deprecated in API level 33

API returns the file object of the protected directory in the device's external storage. This is provided only for a managed profile.

Returns
  • An absolute path of directory for managed profile in the external storage.
Since
API level 19
KNOX 2.6
Multiuser Environment
User Scope

public File getUserDataDir ()

Since: API level 19

Deprecated in API level 33

API returns the applications specific data directory root in the encrypted filesystem. This is the encrypted storage equivalent of Android API getDataDirectory().

Usage:

        An application developer can use this API to get the handle of encrypted data directory path related to the engine information passed to SdpFileSystem.


     try {

         String alias = "alias";

         SdpFileSystem sFS = new SdpFileSystem(this, alias);

         File encDir = sFS.getUserDataDir();

     } catch (SdpException e) {

         e.printStackTrace();

     }

 

Returns
  • An absolute path to the package data directory root.
Since
API level 19
KNOX 2.6
Multiuser Environment
User Scope

public static File getUserDataDir (int userId, String packageName)

Since: API level 19

Deprecated in API level 33

API returns the applications specific data directory root in the encrypted filesystem. This is the encrypted storage equivalent of Android API getDataDirectory().

Usage:

        An application developer can use this API to get the handle of encrypted package directory path.


     int userId = 0;

     File encDir = SdpFileSystem.getUserDataDir(userId, "com.example.packagename");

 

Parameters
userId Android user id.
packageName Application package name.
Returns
  • An absolute path to the package data directory root.
Since
API level 19
KNOX 2.6
Multiuser Environment
User Scope

public boolean isSensitive (File f)

Since: API level 19

Deprecated in API level 33

API checks if the file is sensitive.

Usage:

        An application developer can use this API to check whether target file is sensitive or not.


     try {

         String alias = "alias";

         File file = new File(filename); 

         SdpFileSystem sFS = new SdpFileSystem(this, alias);

         if(sFS.isSensitive(file)) {

             Log.d(TAG, "Sensitive file!");

         }

     } catch (SdpException e) {

         e.printStackTrace();

     }

 

Parameters
f File object representing the file to test for sensitive attribute.
Returns
  • true if file is sensitive, otherwise false.
Since
API level 19
KNOX 2.6
Multiuser Environment
User Scope

public SQLiteDatabase openOrCreateDatabase (String name, int mode, SQLiteDatabase.CursorFactory factory, DatabaseErrorHandler errorHandler)

Since: API level 19

Deprecated in API level 33

API returns a handle to an application specific SQLiteDatabase and creates the database file if it doesn't exist. This is the encrypted storage equivalent of Android API openOrCreateDatabase().

Parameters
name The database name.
mode Operating mode: MODE_PRIVATE for the default operation, MODE_WORLD_READABLE and MODE_WORLD_WRITEABLE to control permissions.
factory An optional factory class that is called to instantiate a cursor when sqlite query is called on the database object.
errorHandler DatabaseErrorHandler to be used when sqlite reports database corruption. If null, DefaultDatabaseErrorHandler is assumed.
Returns
Since
API level 19
KNOX 2.6
Multiuser Environment
User Scope

public SQLiteDatabase openOrCreateDatabase (String name, int mode, SQLiteDatabase.CursorFactory factory)

Since: API level 19

Deprecated in API level 33

API returns a handle to an application specific SQLiteDatabase and creates the database file if it doesn't exist. This is the encrypted storage equivalent of Android API openOrCreateDatabase().

Parameters
name The database name.
mode Operating mode: MODE_PRIVATE for the default operation, MODE_WORLD_READABLE and MODE_WORLD_WRITEABLE to control permissions.
factory An optional factory class that is called to instantiate a cursor when sqlite query is called on the database object.
Returns
Since
API level 19
KNOX 2.6
Multiuser Environment
User Scope

public boolean setSensitive (File f)

Since: API level 19

Deprecated in API level 33

API sets the file(s) as sensitive. A sensitive file can be decrypted only when the SdpEngine is unlocked. This method will fail, if the file is not located in SdpFileSystem or the SdpEngine is removed/tampered with.

NOTE: To determine the file path, do not use the Android API getExternalStorageDirectory(). Use one of the following SDP APIs instead:

getExternalStorageDirectory(), getFilesDir()

Usage:

        An application developer can use this API to set target file as sensitive.


     try {

         String alias = "alias";

         File file = new File(filename); 

         SdpFileSystem sFS = new SdpFileSystem(this, alias);

         sFS.setSensitive(file);

     } catch (SdpException e) {

         e.printStackTrace();

     }

 

Parameters
f File object representing the file to be set as sensitive.
Returns
  • true on success, otherwise false.
Since
API level 19
KNOX 2.6
Multiuser Environment
User Scope