本文整理汇总了Java中android.content.ContentUris.appendId方法的典型用法代码示例。如果您正苦于以下问题:Java ContentUris.appendId方法的具体用法?Java ContentUris.appendId怎么用?Java ContentUris.appendId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.ContentUris
的用法示例。
在下文中一共展示了ContentUris.appendId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notesIdProperties
import android.content.ContentUris; //导入方法依赖的package包/类
public static Uri notesIdProperties(long id) {
Uri.Builder builder = AUTHORITY_URI.buildUpon();
builder = builder.appendPath("notes");
builder = ContentUris.appendId(builder, id);
builder = builder.appendPath("properties");
return builder.build();
}
示例2: booksIdLinks
import android.content.ContentUris; //导入方法依赖的package包/类
public static Uri booksIdLinks(long id) {
Uri.Builder builder = AUTHORITY_URI.buildUpon();
builder = builder.appendPath("books");
builder = ContentUris.appendId(builder, id);
builder = builder.appendPath("links");
return builder.build();
}
示例3: booksIdSaved
import android.content.ContentUris; //导入方法依赖的package包/类
public static Uri booksIdSaved(long id) {
Uri.Builder builder = AUTHORITY_URI.buildUpon();
builder = builder.appendPath("books");
builder = ContentUris.appendId(builder, id);
builder = builder.appendPath("saved");
return builder.build();
}
示例4: queryEventInstances
import android.content.ContentUris; //导入方法依赖的package包/类
@Override
protected Cursor queryEventInstances(long startFrom, long startTo,
String[] projection, String selection, String[] selectionArgs,
String sortOrder) {
Uri.Builder builder = Instances.CONTENT_URI.buildUpon();
ContentUris.appendId(builder, startFrom);
ContentUris.appendId(builder, startTo);
return this.cordova.getActivity().getContentResolver().query(
builder.build(), projection, selection, selectionArgs, sortOrder);
}
示例5: ReadCalendar
import android.content.ContentUris; //导入方法依赖的package包/类
public ArrayList<CalendarEntryDto> ReadCalendar(long timeSpanId) {
Logger.getInstance().Debug(TAG, "ReadCalendar");
ArrayList<CalendarEntryDto> entries = new ArrayList<>();
HashSet<String> calendarIds = new HashSet<>();
ContentResolver contentResolver = _context.getContentResolver();
Cursor cursor = contentResolver.query(Uri.parse("content://com.android.calendar/events"), new String[]{"calendar_id", "title", "description", "dtstart", "dtend", "eventLocation"}, null, null, null);
if (cursor == null) {
Logger.getInstance().Error(TAG, "Cursor is null!");
return new ArrayList<>();
}
Logger.getInstance().Debug(TAG, String.format(Locale.getDefault(), "Cursor count: %d", cursor.getCount()));
try {
if (cursor.getCount() > 0) {
while (cursor.moveToNext()) {
String _id = cursor.getString(0);
calendarIds.add(_id);
}
}
} catch (Exception ex) {
Logger.getInstance().Error(TAG, "Outer: " + ex.toString());
} finally {
cursor.close();
}
Logger.getInstance().Debug(TAG, String.format(Locale.getDefault(), "Size of calendarIds is %d", calendarIds.size()));
for (String id : calendarIds) {
Logger.getInstance().Debug(TAG, String.format(Locale.getDefault(), "CalendarId: %s", id));
Uri.Builder builder = Uri.parse("content://com.android.calendar/instances/when").buildUpon();
long now = new Date().getTime();
ContentUris.appendId(builder, now - timeSpanId);
ContentUris.appendId(builder, now + timeSpanId);
Cursor eventCursor = contentResolver.query(builder.build(),
new String[]{"title", "begin", "end", "allDay"},
CalendarContract.Instances.CALENDAR_ID + "=" + id, null, "startDay ASC, startMinute ASC");
if (eventCursor == null) {
Logger.getInstance().Error(TAG, "EventCursor is null!");
continue;
}
Logger.getInstance().Debug(TAG, String.format(Locale.getDefault(), "eventCursor count: %d", eventCursor.getCount()));
if (eventCursor.getCount() > 0) {
if (eventCursor.moveToFirst()) {
do {
// Properties
final String title = eventCursor.getString(0);
final Date begin = new Date(eventCursor.getLong(1));
final Date end = new Date(eventCursor.getLong(2));
final boolean allDay = !eventCursor.getString(3).equals("0");
CalendarEntryDto newEntry = new CalendarEntryDto(title, begin, end, allDay);
Logger.getInstance().Debug(TAG, String.format(Locale.getDefault(), "Adding new calendar entry %s", newEntry));
entries.add(newEntry);
} while (eventCursor.moveToNext());
}
}
eventCursor.close();
}
Logger.getInstance().Debug(TAG, String.format(Locale.getDefault(), "Size of entry list is %d", entries.size()));
entries.sort(Comparator.comparing(CalendarEntryDto::GetBegin));
return entries;
}