当前位置: 首页>>代码示例>>Java>>正文


Java Calendars._ID属性代码示例

本文整理汇总了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();
        }
    }
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:24,代码来源:ZenModeEventRuleSettings.java

示例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;
}
 
开发者ID:caseydavenport,项目名称:biermacht,代码行数:19,代码来源:BrewTimerStepFragment.java

示例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;
	}

}
 
开发者ID:DHBWLoerrach,项目名称:campus-app,代码行数:28,代码来源:CalendarManager.java

示例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());
    }
}
 
开发者ID:tuxskar,项目名称:caluma,代码行数:26,代码来源:HomeActivity.java

示例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());
    }
}
 
开发者ID:tuxskar,项目名称:caluma,代码行数:24,代码来源:StudentHomeActivity.java

示例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;
	}

}
 
开发者ID:dan-42,项目名称:DHBWCampusApp,代码行数:29,代码来源:CalendarManager.java

示例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);
}
 
开发者ID:henrichg,项目名称:PhoneProfilesPlus,代码行数:32,代码来源:CalendarsMultiSelectDialogPreference.java

示例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;
}
 
开发者ID:DHBWLoerrach,项目名称:campus-app,代码行数:31,代码来源:CalendarManager.java


注:本文中的android.provider.CalendarContract.Calendars._ID属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。