本文整理汇总了Java中android.provider.CalendarContract.Calendars._ID属性的典型用法代码示例。如果您正苦于以下问题:Java Calendars._ID属性的具体用法?Java Calendars._ID怎么用?Java Calendars._ID使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.provider.CalendarContract.Calendars
的用法示例。
在下文中一共展示了Calendars._ID属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCalendars
public static void addCalendars(Context context, List<CalendarInfo> outCalendars) {
final String primary = "\"primary\"";
final String[] projection = { Calendars._ID, Calendars.CALENDAR_DISPLAY_NAME,
"(" + Calendars.ACCOUNT_NAME + "=" + Calendars.OWNER_ACCOUNT + ") AS " + primary };
final String selection = primary + " = 1";
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(Calendars.CONTENT_URI, projection,
selection, null, null);
if (cursor == null) {
return;
}
while (cursor.moveToNext()) {
final CalendarInfo ci = new CalendarInfo();
ci.name = cursor.getString(1);
ci.userId = context.getUserId();
outCalendars.add(ci);
}
} finally {
if (cursor != null) {
cursor.close();
}
}
}
示例2: getCalendarId
private long getCalendarId() {
String[] projection = new String[]{Calendars._ID};
//String selection = Calendars.ACCOUNT_NAME + "=Biermacht AND" + Calendars.ACCOUNT_TYPE + "=" + CalendarContract.ACCOUNT_TYPE_LOCAL;
String selection = "(" + Calendars.ACCOUNT_NAME + " = ?) AND (" + Calendars.ACCOUNT_TYPE + " = ?)";
String[] selectionArgs = new String[]{"Biermacht", CalendarContract.ACCOUNT_TYPE_LOCAL};
// use the same values as above:
//String[] selArgs = new String[]{"Biermacht", CalendarContract.ACCOUNT_TYPE_LOCAL};
Cursor cursor = c.getContentResolver().query(Calendars.CONTENT_URI,
projection,
selection,
selectionArgs,
null);
if (cursor.moveToFirst()) {
return cursor.getLong(0);
}
return - 1;
}
示例3: deleteCalendar
/**
* Deletes all Events from the EventsDB and the Calendar from the CalendarDB
* identified by the _ID and ACCOUNT_TYPE
*
* @param mContext
* @param account
* @return true if delete was successful
*/
public boolean deleteCalendar(Account account, long calendarId) {
deleteAllEvents(account, calendarId);
ContentResolver cr = mContext.getContentResolver();
String selection = "((" + Calendars._ID + " = ?) AND (" + Calendars.ACCOUNT_TYPE + " = ?))";
String[] selectionArgs = new String[] { Long.toString(calendarId), Constants.ACCOUNT_TYPE };
long ret = cr.delete(Calendars.CONTENT_URI, selection, selectionArgs);
if (ret == 1) {
return true;
} else if (ret == 0) {
return false;
} else {
Log.w(TAG, "WARNING deleteCalendar() deleted " + ret + " rows, should be only one!");
return true;
}
}
示例4: populateCalendars
public void populateCalendars() {
String[] projection = new String[]{Calendars._ID, Calendars.NAME,
Calendars.ACCOUNT_NAME, Calendars.ACCOUNT_TYPE};
Cursor calCursor = this
.getActivity()
.getContentResolver()
.query(Calendars.CONTENT_URI, projection, null, null,
Calendars._ID + " DESC");
calendarNames = new ArrayList<String>();
calendarAccounts = new ArrayList<String>();
calendarTypes = new ArrayList<String>();
calendarIds = new ArrayList<Long>();
if (calCursor.moveToFirst()) {
do {
String name = calCursor.getString(1);
if (name == null) {
name = "Sin nombre";
}
calendarNames.add(name);
calendarAccounts.add(calCursor.getString(2));
calendarTypes.add(calCursor.getString(3));
calendarIds.add(calCursor.getLong(0));
} while (calCursor.moveToNext());
}
}
示例5: populateCalendars
public void populateCalendars() {
String[] projection = new String[]{Calendars._ID, Calendars.NAME,
Calendars.ACCOUNT_NAME, Calendars.ACCOUNT_TYPE};
Cursor calCursor = this.getActivity().getContentResolver()
.query(Calendars.CONTENT_URI, projection,
null, null, Calendars._ID + " DESC");
calendarNames = new ArrayList<String>();
calendarAccounts = new ArrayList<String>();
calendarTypes = new ArrayList<String>();
calendarIds = new ArrayList<Long>();
if (calCursor.moveToFirst()) {
do {
String name = calCursor.getString(1);
if (name == null) {
name = "Sin nombre";
}
calendarNames.add(name);
calendarAccounts.add(calCursor.getString(2));
calendarTypes.add(calCursor.getString(3));
calendarIds.add(calCursor.getLong(0));
} while (calCursor.moveToNext());
}
}
示例6: deleteCalendar
/**
* Deletes all Events from the EventsDB and the Calendar from the CalendarDB
* identified by the _ID and ACCOUNT_TYPE
*
* @param mContext
* @param account
* @return true if delete was successful
*/
public boolean deleteCalendar(Account account, long calendarId) {
deleteAllEvents(account, calendarId);
Uri url = asSyncAdapter(Calendars.CONTENT_URI, account.name, account.type);
ContentResolver cr = mContext.getContentResolver();
String selection = "((" + Calendars._ID + " = ?) AND (" + Calendars.ACCOUNT_TYPE + " = ?))";
String[] selectionArgs = new String[] { Long.toString(calendarId), Constants.ACCOUNT_TYPE };
long ret = cr.delete(Calendars.CONTENT_URI, selection, selectionArgs);
if (ret == 1) {
return true;
} else if (ret == 0) {
return false;
} else {
Log.w(TAG, "WARNING deleteCalendar() deleted " + ret + " rows, should be only one!");
return true;
}
}
示例7: setSummaryCMSDP
@SuppressLint("MissingPermission")
private void setSummaryCMSDP()
{
String prefVolumeDataSummary = _context.getString(R.string.calendars_multiselect_summary_text_not_selected);
if (Permissions.checkCalendar(_context)) {
if (!value.isEmpty()) {
String[] splits = value.split("\\|");
if (splits.length == 1) {
boolean found = false;
Cursor cur;
ContentResolver cr = _context.getContentResolver();
Uri uri = Calendars.CONTENT_URI;
String selection = Calendars._ID + "=" + splits[0];
//noinspection MissingPermission
cur = cr.query(uri, CALENDAR_PROJECTION, selection, null, null);
if (cur != null) {
//while (cur.moveToNext()) {
if (cur.moveToFirst()) {
found = true;
prefVolumeDataSummary = cur.getString(PROJECTION_DISPLAY_NAME_INDEX);
//break;
}
cur.close();
}
if (!found)
prefVolumeDataSummary = _context.getString(R.string.calendars_multiselect_summary_text_selected) + ": " + splits.length;
} else
prefVolumeDataSummary = _context.getString(R.string.calendars_multiselect_summary_text_selected) + ": " + splits.length;
}
}
setSummary(prefVolumeDataSummary);
}
示例8: getCalendarId
/**
* returns the CalendarID depending on the account.name and acount.type
*
* @param mContext
* @param account
* @return id
*/
public long getCalendarId(Account account) {
Cursor cur = null;
long calendarId = -1;
ContentResolver cr = mContext.getContentResolver();
String[] projection = new String[] { Calendars._ID };
String selection = "((" + Calendars.ACCOUNT_NAME + " = ?) AND (" + Calendars.ACCOUNT_TYPE + " = ?) )";
String[] selectionArgs = new String[] { account.name, account.type };
cur = cr.query(Calendars.CONTENT_URI, projection, selection, selectionArgs, null);
if (cur.getCount() == 1 && cur.moveToFirst()) {
calendarId = cur.getLong(0);
} else {
Log.e(TAG, "getCalendarId() FATAL ERROR cur.getCount()=" + cur.getCount());
}
cur.close();
return calendarId;
}