DataService

Describe the class here - This is a template documentation page
class DataService

The DataService class provides the interface to utilize the Lightning Database (cloud data storage) capabilities of playPORTAL.

Two data stores are auto-created (or opened) for each user. They are:

  • User's private app data

  • Global app data (shared)

Data can be stored and retrieved from either of these data stores, in addition other data stores can be created as needed. All data read/written must be JSON. The read/write methods utilize JsonObjects and supported marshaling routines.

Methods

createBucket

Creates a bucket for use by this user. The bucket can be private or shared with other users.

public void createBucket(String bucketname, ArrayList<String> bucketUsers, Boolean isPublic, Context CONTEXT, _CallbackFunction._Data cb)

Property

Type

Description

bucketName

String

Name for the bucket to create, used for all future references.

bucketUsers

ArrayList<String>

List of users that have permissions to use the bucket

isPublic

Boolean

If true, bucket is public.

CONTEXT

Context

Android Context.

cb

CallbackFunction.Data

Callback function invoked on completion of the create call.

read

Reads data from a given bucket.

public public void read(String bucketname, String key, _CallbackFunction._Data cb)

Property

Type

Description

bucketName

String

Name of the bucket to read from

key

String

Data is stored as KV pairs; this is the K

cb

CallbackFunction.Data

Callback invoked on completion of the read call.

write

Write JSON data to a given bucket. For convenience, write methods are overloaded to support writing of primitive Java types as well as JSON objects.

public void write(String bucketname, String key, JSONObject value, _CallbackFunction._Data cb )
public void write(String bucketname, String key, Boolean value, _CallbackFunction._Data cb )
public void write(String bucketname, String key, String value, _CallbackFunction._Data cb )
public void write(String bucketname, String key, Integer value, _CallbackFunction._Data cb )

Property

Type

Description

bucketName

String

Name of bucket to write to

key

String

Data is stored as KV pairs; this is the K

value

JSONObject (or an intrinsic type of Bool, String or Integer)

data to write

cb

CallbackFunction.Data

data written