本文整理汇总了C#中Android.App.Activity.ManagedQuery方法的典型用法代码示例。如果您正苦于以下问题:C# Activity.ManagedQuery方法的具体用法?C# Activity.ManagedQuery怎么用?C# Activity.ManagedQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.App.Activity
的用法示例。
在下文中一共展示了Activity.ManagedQuery方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getNoteIdByGUID
public static int getNoteIdByGUID(Activity activity, string guid)
{
int id = 0;
// get the notes ids
string[] whereArgs = { guid };
ICursor cursor = activity.ManagedQuery(Tomdroid.CONTENT_URI, ID_PROJECTION, Note.GUID+"=?", whereArgs, null);
// cursor must not be null and must return more than 0 entry
if (!(cursor == null || cursor.Count == 0)) {
cursor.MoveToFirst();
id = cursor.GetInt(cursor.GetColumnIndexOrThrow(Note.ID));
}
else {
// TODO send an error to the user
TLog.d(TAG, "Cursor returned null or 0 notes");
}
return id;
}
示例2: getTitles
// gets the titles of the notes present in the db, used in ViewNote.buildLinkifyPattern()
public static ICursor getTitles(Activity activity)
{
string where = Note.TAGS + " NOT LIKE '%system:deleted%'";
// get a cursor containing the notes titles
return activity.ManagedQuery(Tomdroid.CONTENT_URI, TITLE_PROJECTION, where, null, null);
}
示例3: getNote
// gets a note from the content provider
public static Note getNote(Activity activity, Uri uri)
{
Note note = null;
// can we find a matching note?
ICursor cursor = activity.ManagedQuery(uri, FULL_PROJECTION, null, null, null);
// cursor must not be null and must return more than 0 entry
if (!(cursor == null || cursor.Count == 0)) {
// create the note from the cursor
cursor.MoveToFirst();
string noteContent = cursor.GetString(cursor.GetColumnIndexOrThrow(Note.NOTE_CONTENT));
string noteTitle = cursor.GetString(cursor.GetColumnIndexOrThrow(Note.TITLE));
string noteChangeDate = cursor.GetString(cursor.GetColumnIndexOrThrow(Note.MODIFIED_DATE));
string noteTags = cursor.GetString(cursor.GetColumnIndexOrThrow(Note.TAGS));
string noteGUID = cursor.GetString(cursor.GetColumnIndexOrThrow(Note.GUID));
int noteDbid = cursor.GetInt(cursor.GetColumnIndexOrThrow(Note.ID));
note = new Note();
note.setTitle(noteTitle);
note.setXmlContent(stripTitleFromContent(noteContent, noteTitle));
note.setLastChangeDate(noteChangeDate);
note.setTags(noteTags);
note.setGuid(noteGUID);
note.setDbId(noteDbid);
}
cursor.Close();
return note;
}
示例4: getNewNotes
/**
* getNewNotes
* get a guid list of notes that are newer than latest sync date
* @param activity
*/
public static ICursor getNewNotes(Activity activity)
{
ICursor cursor = activity.ManagedQuery(Tomdroid.CONTENT_URI, DATE_PROJECTION, "strftime('%s', "+Note.MODIFIED_DATE+") > strftime('%s', '"+Preferences.GetString(Preferences.Key.LATEST_SYNC_DATE)+"')", null, null);
return cursor;
}
示例5: getGuids
// gets the ids of the notes present in the db, used in SyncService.deleteNotes()
public static ICursor getGuids(Activity activity)
{
// get a cursor containing the notes guids
return activity.ManagedQuery(Tomdroid.CONTENT_URI, GUID_PROJECTION, null, null, null);
}
示例6: getAllNotesAsNotes
// this function gets all non-deleted notes as notes in an array
public static Note[] getAllNotesAsNotes(Activity activity, bool includeNotebookTemplates)
{
Uri uri = Tomdroid.CONTENT_URI;
string where = "("+Note.TAGS + " NOT LIKE '%" + "system:deleted" + "%')";
string orderBy;
if (!includeNotebookTemplates) {
where += " AND (" + Note.TAGS + " NOT LIKE '%" + "system:template" + "%')";
}
orderBy = Note.MODIFIED_DATE + " DESC";
ICursor cursor = activity.ManagedQuery(uri, FULL_PROJECTION, where, null, orderBy);
if (cursor == null || cursor.Count == 0) {
TLog.d(TAG, "no notes in cursor");
return null;
}
TLog.d(TAG, "{0} notes in cursor",cursor.Count);
Note[] notes = new Note[cursor.Count];
cursor.MoveToFirst();
int key = 0;
while(!cursor.IsAfterLast) {
string noteContent = cursor.GetString(cursor.GetColumnIndexOrThrow(Note.NOTE_CONTENT));
string noteTitle = cursor.GetString(cursor.GetColumnIndexOrThrow(Note.TITLE));
string noteChangeDate = cursor.GetString(cursor.GetColumnIndexOrThrow(Note.MODIFIED_DATE));
string noteTags = cursor.GetString(cursor.GetColumnIndexOrThrow(Note.TAGS));
string noteGUID = cursor.GetString(cursor.GetColumnIndexOrThrow(Note.GUID));
int noteDbid = cursor.GetInt(cursor.GetColumnIndexOrThrow(Note.ID));
Note note = new Note();
note.setTitle(noteTitle);
note.setXmlContent(stripTitleFromContent(noteContent, noteTitle));
note.setLastChangeDate(noteChangeDate);
note.addTag(noteTags);
note.setGuid(noteGUID);
note.setDbId(noteDbid);
notes[key++] = note;
cursor.MoveToNext();
}
cursor.Close();
return notes;
}
示例7: getAllNotes
public static ICursor getAllNotes(Activity activity, bool includeNotebookTemplates)
{
// get a cursor representing all notes from the NoteProvider
Uri notes = Tomdroid.CONTENT_URI;
string where = "("+Note.TAGS + " NOT LIKE '%" + "system:deleted" + "%')";
if (!includeNotebookTemplates) {
where += " AND (" + Note.TAGS + " NOT LIKE '%" + "system:template" + "%')";
}
return activity.ManagedQuery(notes, LIST_PROJECTION, where, null, sortOrder);
}