本文整理汇总了Java中android.provider.CalendarContract.Calendars.ACCOUNT_NAME属性的典型用法代码示例。如果您正苦于以下问题:Java Calendars.ACCOUNT_NAME属性的具体用法?Java Calendars.ACCOUNT_NAME怎么用?Java Calendars.ACCOUNT_NAME使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.provider.CalendarContract.Calendars
的用法示例。
在下文中一共展示了Calendars.ACCOUNT_NAME属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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());
}
}
示例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: getCalendarCrusor
private static Cursor getCalendarCrusor(Context context)
{
String[] EVENT_PROJECTION = new String[] {
BaseColumns._ID, // 0
Calendars.ACCOUNT_NAME, // 1
Calendars.CALENDAR_DISPLAY_NAME, // 2
Calendars.OWNER_ACCOUNT // 3
};
// String[] EVENT_PROJECTION = new String[] {
// "_id", "name"
// };
// The indices for the projection array above.
Cursor cursor = null;
ContentResolver cr = context.getContentResolver();
Uri uri = Calendars.CONTENT_URI;
String selection = "((" + Calendars.ACCOUNT_NAME + " = ?) AND ("
+ Calendars.ACCOUNT_TYPE + " = ?) AND ("
+ Calendars.OWNER_ACCOUNT + " = ?))";
String[] selectionArgs = new String[] {"com.google"};
// Submit the query and get a Cursor object back.
return cr.query(uri, EVENT_PROJECTION, null, null, null);
}
示例6: queryCalendar
public void queryCalendar(View view) {
// Run query
Cursor cur = null;
ContentResolver cr = getContentResolver();
Uri uri = Calendars.CONTENT_URI;
String selection = "((" + Calendars.ACCOUNT_NAME + " = ?) AND ("
+ Calendars.ACCOUNT_TYPE + " = ?))";
// Replace this with your own user and account type
String[] selectionArgs = new String[] { "[email protected]",
"com.google" };
// Submit the query and get a Cursor object back.
cur = cr.query(uri, EVENT_PROJECTION, selection, selectionArgs, null);
Toast.makeText(this, String.valueOf(cur.getCount()), Toast.LENGTH_LONG)
.show();
// Use the cursor to step through the returned records
while (cur.moveToNext()) {
long calID = 0;
String displayName = null;
String accountName = null;
// Get the field values
calID = cur.getLong(PROJECTION_ID_INDEX);
displayName = cur.getString(PROJECTION_DISPLAY_NAME_INDEX);
accountName = cur.getString(PROJECTION_ACCOUNT_NAME_INDEX);
// Do something with the values...
Toast.makeText(this, "Calendar " + displayName, Toast.LENGTH_SHORT)
.show();
}
}
示例7: 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;
}