本文整理匯總了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;
}