public class

FileCacheSqlHelper

extends SQLiteOpenHelper
java.lang.Object
   ↳ android.database.sqlite.SQLiteOpenHelper
     ↳ com.kinvey.android.offline.FileCacheSqlHelper

Class Overview

This class manages a sqlite database for maintaining metadata about cached files. Each file must have a unique identifier and a filename. If the filename is unique, that can be used as the unique id.

This class provides methods for saving new records, retrieving records, and deleting records.

Summary

Public Methods
void deleteRecord(String id)
Remove a record from the table
void dump()
Dump the contents of the database to the logs, used for debugging purposes.
String getFileNameForId(String id)
Return the filename of the file on disc relavant to the provided id
synchronized static FileCacheSqlHelper getInstance(Context context)
This class is a synchronized Singleton, and this is how you get an instance of it.
void insertRecord(Client client, FileMetaData meta)
Insert a new record into the file cache metadata table.
void onCreate(SQLiteDatabase sqLiteDatabase)
Called by android first time this database is accessed, to create it.
void onUpgrade(SQLiteDatabase sqLiteDatabase, int current, int next)
void runCommand(String command, SQLiteDatabase db)
Execute an arbitrary sqlite command against a sqlite database.
[Expand]
Inherited Methods
From class android.database.sqlite.SQLiteOpenHelper
From class java.lang.Object

Public Methods

public void deleteRecord (String id)

Remove a record from the table

Parameters
id the id of the record to remove

public void dump ()

Dump the contents of the database to the logs, used for debugging purposes.

public String getFileNameForId (String id)

Return the filename of the file on disc relavant to the provided id

Parameters
id the id of the filename to look up
Returns
  • the filename of the file or null

public static synchronized FileCacheSqlHelper getInstance (Context context)

This class is a synchronized Singleton, and this is how you get an instance of it.

Parameters
context the current active application context
Returns
  • an instance of the OfflineHelper class

public void insertRecord (Client client, FileMetaData meta)

Insert a new record into the file cache metadata table.

Parameters
client a Kinvey Client, needed for JSON serialization
meta the FileMetaData object for the file, containing an id and a filename

public void onCreate (SQLiteDatabase sqLiteDatabase)

Called by android first time this database is accessed, to create it.

public void onUpgrade (SQLiteDatabase sqLiteDatabase, int current, int next)

public void runCommand (String command, SQLiteDatabase db)

Execute an arbitrary sqlite command against a sqlite database.

no validation is performed here.

Parameters
command the command to execute
db the database to execute the command against