Sony Addon SDK public class

NotificationUtil

This project is no longer being supported and will not get any further updates.
extends java.lang.Object
  1. java.lang.Object
  2. com.sonyericsson.extras.liveware.extension.util.notification.NotificationUtil

Class Overview

Summary

Constants
int INVALID_ID Invalid id
Fields
public static final java.lang.String EVENT_ID Event Id to use in projection, selection and sortOrder when quering URI
Public Methods
static long getSourceId(Context context, java.lang.String extensionSpecificId)

Get source id associated with extension specific id of the source.

static java.lang.String getExtensionSpecificId(Context context, long sourceId)

Get extension specific id.

static int deleteAllEvents(Context context, java.lang.String extensionSpecificId)

Delete all events associated with a extension specific id

static int deleteAllEvents(Context context)

Delete all events associated with this extension

static int markAllEventsAsRead(Context context)

Mark all events as read

static Uri addEvent(Context context, ContentValues eventValues)

Add new event to Event table

static java.util.ArrayList<java.lang.Integer> getSourceIds(Context context, boolean enabled)

Get source ids associated with extension.

static java.util.ArrayList<java.lang.String> getExtensionSpecificIds(Context context)

Get Extension Specific Ids associated with an extension.

static java.util.ArrayList<java.lang.Long> getSourceIds(Context context)

Get all source ids associated with extension

static java.lang.String getFriendKey(Context context, long eventId)

Get friend key associated with event id

static Cursor queryEvents(Context context, java.lang.String[] projection, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String sortOrder)

Query URI, limit query to affect events in this extension only.

static Cursor queryEventsFromEnabledSources(Context context, java.lang.String[] projection, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String sortOrder)

Query URI, limit query to affect events in this extension only and sources that are enabled.

static int updateEvents(Context context, ContentValues values, java.lang.String where, java.lang.String[] selectionArgs)

Update events, limit update to affect events in this extension only.

static int deleteEvents(Context context, java.lang.String where, java.lang.String[] selectionArgs)

Delete events, limit delete to affect events in this extension only.

static java.lang.String getEventsWhere(Context context)

Get where string that limits a queries to URI to affect events that belongs to this extension only

static Cursor querySources(Context context, java.lang.String[] projection, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String sortOrder)

Query sources, limit scope to sources in this extension

static int updateSources(Context context, ContentValues values, java.lang.String where, java.lang.String[] selectionArgs)

Update sources, limit scope to sources in this extension

static int deleteSources(Context context, java.lang.String where, java.lang.String[] selectionArgs)

Delete sources, limit scope to sources in this extension

static java.lang.String getSourcesWhere(Context context)

Get where string that limits a queries to URI and URI to affect sources and source events that belongs to this extension only

Constants

public static final int INVALID_ID

Invalid id

Constant Value: -1 (0xffffffffffffffff)

Fields

public static final java.lang.String EVENT_ID

Event Id to use in projection, selection and sortOrder when quering URI

See Also

Public Methods

public static long getSourceId(Context context, java.lang.String extensionSpecificId)

Get source id associated with extension specific id of the source.

Parameters
context Context with permissions to access Notification db
extensionSpecificId Extension specific identifier of the source.
Returns

Source id, INVALID_ID if not found

public static java.lang.String getExtensionSpecificId(Context context, long sourceId)

Get extension specific id.

Parameters
context Context with permissions to access Notification db
sourceId The source id.
Returns

Extension specific id, null if not found

public static int deleteAllEvents(Context context, java.lang.String extensionSpecificId)

Delete all events associated with a extension specific id

Parameters
context The context.
extensionSpecificId The extension specific id
Returns

The number of events that was deleted or INVALID_ID on failure

public static int deleteAllEvents(Context context)

Delete all events associated with this extension

Parameters
context The context.
Returns

The number of events that was deleted or INVALID_ID on failure

public static int markAllEventsAsRead(Context context)

Mark all events as read

Parameters
context
Returns

Number of updated rows in event table, INVALID_ID on failure

public static Uri addEvent(Context context, ContentValues eventValues)

Add new event to Event table

Parameters
context Context with permissions to access Notification db
eventValues A reference to the notification com.sonyericsson.extras .liveware.aef.notification.Notification.
Returns

Uri to the created event

public static java.util.ArrayList<java.lang.Integer> getSourceIds(Context context, boolean enabled)

Get source ids associated with extension.

Parameters
context Context with permissions to access Notification db
enabled
Returns

Source ids, empty array if not found

public static java.util.ArrayList<java.lang.String> getExtensionSpecificIds(Context context)

Get Extension Specific Ids associated with an extension.

Parameters
context Context with permissions to access Notification db
Returns

Extension Specific Ids ids for enabled sources, empty array if not found

public static java.util.ArrayList<java.lang.Long> getSourceIds(Context context)

Get all source ids associated with extension

Parameters
context Context with permissions to access Notification db
Returns

All source ids, empty array if not found

public static java.lang.String getFriendKey(Context context, long eventId)

Get friend key associated with event id

Parameters
context Context with permissions to access Notification db
eventId Id of event
Returns

Event title or null if not found.

public static Cursor queryEvents(Context context, java.lang.String[] projection, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String sortOrder)

Query URI, limit query to affect events in this extension only. Returned cursor is a join between URI and URI. Queries executed on URI can also be executed by this method if all references to _ID are replaced with event._id

This method is mainly aimed for extensions that shares user id and process in which case they can access and modify data that belongs to other extensions.

Note that no runtime exceptions, such as SecurityException and SQLException, will be handled by this method. Exceptions shall instead be handled in the calling method if needed.

This method is also convenient when querying events that belongs to a specific EXTENSION_SPECIFIC_ID since no extra lookup of the source id is needed.

Parameters
context The context
projection A list of which columns to return. Passing null will return all columns, which is inefficient. The projection can contain all columns in Notification.EventColumns and all columns in Notification.SourceColumns except for _ID
selection A filter declaring which rows to return, formatted as an SQL WHERE clause (excluding the WHERE itself). Passing null will return all rows for the given URI.
selectionArgs Arguments to where String
sortOrder How to order the rows, formatted as an SQL ORDER BY clause (excluding the ORDER BY itself). Passing null will use the default sort order, which may be unordered.
Returns

A Cursor object, which is positioned before the first entry, or null

public static Cursor queryEventsFromEnabledSources(Context context, java.lang.String[] projection, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String sortOrder)

Query URI, limit query to affect events in this extension only and sources that are enabled. Returned cursor is a join between URI and URI. Queries executed on URI can also be executed by this method if all references to _ID are replaced with event._id

This method is mainly aimed for extensions that shares user id and process in which case they can access and modify data that belongs to other extensions.

Note that no runtime exceptions, such as SecurityException and SQLException, will be handled by this method. Exceptions shall instead be handled in the calling method if needed.

This method is also convenient when querying events that belongs to a specific EXTENSION_SPECIFIC_ID since no extra lookup of the source id is needed.

Parameters
context The context
projection A list of which columns to return. Passing null will return all columns, which is inefficient. The projection can contain all columns in Notification.EventColumns and all columns in Notification.SourceColumns except for _ID
selection A filter declaring which rows to return, formatted as an SQL WHERE clause (excluding the WHERE itself). Passing null will return all rows for the given URI.
selectionArgs Arguments to where String
sortOrder How to order the rows, formatted as an SQL ORDER BY clause (excluding the ORDER BY itself). Passing null will use the default sort order, which may be unordered.
Returns

A Cursor object, which is positioned before the first entry, or null

public static int updateEvents(Context context, ContentValues values, java.lang.String where, java.lang.String[] selectionArgs)

Update events, limit update to affect events in this extension only.

This method is mainly aimed for extensions that shares user id and process in which case they can access and modify data that belongs to other extensions.

Note that no runtime exceptions, such as SecurityException and SQLException, will be handled by this method. Exceptions shall instead be handled in the calling method if needed.

Parameters
context The context
values The new field values. The key is the column name for the field. A null value will remove an existing field value.
where A filter to apply to rows before updating, formatted as an SQL WHERE clause (excluding the WHERE itself).
selectionArgs Arguments to where String
Returns

The number of rows updated

public static int deleteEvents(Context context, java.lang.String where, java.lang.String[] selectionArgs)

Delete events, limit delete to affect events in this extension only.

This method is mainly aimed for extensions that shares user id and process in which case they can access and modify data that belongs to other extensions.

Note that no runtime exceptions, such as SecurityException and SQLException, will be handled by this method. Exceptions shall instead be handled in the calling method if needed.

Parameters
context The context
where A filter to apply to rows before deleting, formatted as an SQL WHERE clause (excluding the WHERE itself).
selectionArgs Arguments to where String
Returns

The number of rows deleted

public static java.lang.String getEventsWhere(Context context)

Get where string that limits a queries to URI to affect events that belongs to this extension only

Parameters
context The context
Returns

The where string:

Template: sourceId IN ( sourceId1, sourceId2, ... )

public static Cursor querySources(Context context, java.lang.String[] projection, java.lang.String selection, java.lang.String[] selectionArgs, java.lang.String sortOrder)

Query sources, limit scope to sources in this extension

This method is mainly aimed for extensions that shares user id and process in which case they can access and modify data that belongs to other extensions.

Note that no runtime exceptions, such as SecurityException and SQLException, will be handled by this method. Exceptions shall instead be handled in the calling method if needed.

Parameters
context The context
projection A list of which columns to return. Passing null will return all columns, which is inefficient.
selection A filter declaring which rows to return, formatted as an SQL WHERE clause (excluding the WHERE itself). Passing null will return all rows for the given URI.
selectionArgs Arguments to where String
sortOrder How to order the rows, formatted as an SQL ORDER BY clause (excluding the ORDER BY itself). Passing null will use the default sort order, which may be unordered.
Returns

A Cursor object, which is positioned before the first entry, or null

public static int updateSources(Context context, ContentValues values, java.lang.String where, java.lang.String[] selectionArgs)

Update sources, limit scope to sources in this extension

This method is mainly aimed for extensions that shares user id and process in which case they can access and modify data that belongs to other extensions.

Note that no runtime exceptions, such as SecurityException and SQLException, will be handled by this method. Exceptions shall instead be handled in the calling method if needed.

Parameters
context The context
values The new field values. The key is the column name for the field. A null value will remove an existing field value.
where A filter to apply to rows before updating, formatted as an SQL WHERE clause (excluding the WHERE itself).
selectionArgs Arguments to where String
Returns

The number of rows updated

public static int deleteSources(Context context, java.lang.String where, java.lang.String[] selectionArgs)

Delete sources, limit scope to sources in this extension

This method is mainly aimed for extensions that shares user id and process in which case they can access and modify data that belongs to other extensions.

Note that no runtime exceptions, such as SecurityException and SQLException, will be handled by this method. Exceptions shall instead be handled in the calling method if needed.

Parameters
context The context
where A filter to apply to rows before deleting, formatted as an SQL WHERE clause (excluding the WHERE itself).
selectionArgs Arguments to where String
Returns

The number of rows deleted

public static java.lang.String getSourcesWhere(Context context)

Get where string that limits a queries to URI and URI to affect sources and source events that belongs to this extension only

Parameters
context The context
Returns

The where string