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


C# ICursor.MoveToFirst方法代码示例

本文整理汇总了C#中ICursor.MoveToFirst方法的典型用法代码示例。如果您正苦于以下问题:C# ICursor.MoveToFirst方法的具体用法?C# ICursor.MoveToFirst怎么用?C# ICursor.MoveToFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICursor的用法示例。


在下文中一共展示了ICursor.MoveToFirst方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create_Database

        public void Create_Database()
        {
            HashSet<String> tableNameHashSet = new HashSet<String> ();
            tableNameHashSet.Add (WeatherContractOpen.LocationEntryOpen.TABLE_NAME);
            tableNameHashSet.Add (WeatherContractOpen.WeatherEntryOpen.TABLE_NAME);

            context.DeleteDatabase (WeatherDbOpenHelper.DATABASE_NAME);
            SQLiteDatabase db = new WeatherDbOpenHelper (
                                    this.context).WritableDatabase;
            Assert.AreEqual (true, db.IsOpen);

            // have we created the tables we want?
            c = db.RawQuery ("SELECT name FROM sqlite_master WHERE type='table'", null);

            Assert.IsTrue (c.MoveToFirst (), "Error: This means that the database has not been created correctly");

            // verify that the tables have been created
            do {
                tableNameHashSet.Remove (c.GetString (0));
            } while(c.MoveToNext ());

            // if this fails, it means that your database doesn't contain both the location entry
            // and weather entry tables
            Assert.IsTrue (tableNameHashSet.Count == 0, "Error: Your database was created without both the location entry and weather entry tables");

            // now, do our tables contain the correct columns?
            c = db.RawQuery ("PRAGMA table_info(" + WeatherContractOpen.LocationEntryOpen.TABLE_NAME + ")",
                null);

            Assert.IsTrue (c.MoveToFirst (), "Error: This means that we were unable to query the database for table information.");

            // Build a HashSet of all of the column names we want to look for
            HashSet<String> locationColumnHashSet = new HashSet<String> ();
            locationColumnHashSet.Add (WeatherContractOpen.LocationEntryOpen._ID);
            locationColumnHashSet.Add (WeatherContractOpen.LocationEntryOpen.COLUMN_CITY_NAME);
            locationColumnHashSet.Add (WeatherContractOpen.LocationEntryOpen.COLUMN_COORD_LAT);
            locationColumnHashSet.Add (WeatherContractOpen.LocationEntryOpen.COLUMN_COORD_LONG);
            locationColumnHashSet.Add (WeatherContractOpen.LocationEntryOpen.COLUMN_LOCATION_SETTING);

            int columnNameIndex = c.GetColumnIndex ("name");
            do {
                String columnName = c.GetString (columnNameIndex);
                locationColumnHashSet.Remove (columnName);
            } while(c.MoveToNext ());

            // if this fails, it means that your database doesn't contain all of the required location
            // entry columns
            Assert.IsTrue (locationColumnHashSet.Count == 0, "Error: The database doesn't contain all of the required location entry columns");
            db.Close ();
        }
开发者ID:Screech129,项目名称:WeatherApp,代码行数:50,代码来源:TestDbOpen.cs

示例2: OnTrackQueryComplete

		/**
	     * Handle {@link TracksQuery} {@link Cursor}.
	     */
		private void OnTrackQueryComplete (ICursor cursor)
		{
			try {
				if (!cursor.MoveToFirst ()) {
					return;
				}
	
				// Use found track to build title-bar
				ActivityHelper activityHelper = ((BaseActivity)Activity).ActivityHelper;
				activityHelper.SetActionBarTitle (new Java.Lang.String (cursor.GetString (TracksQuery.TRACK_NAME)));
				activityHelper.SetActionBarColor (new Color (cursor.GetInt (TracksQuery.TRACK_COLOR)));
			} finally {
				cursor.Close ();
			}
		}
开发者ID:CHANDAN145,项目名称:monodroid-samples,代码行数:18,代码来源:SessionDetailFragment.cs

示例3: OnSessionQueryComplete

		/**
	     * Handle {@link SessionsQuery} {@link Cursor}.
	     */
		private void OnSessionQueryComplete (ICursor cursor)
		{
			try {
				mSessionCursor = true;
				if (!cursor.MoveToFirst ()) {
					return;
				}
	
				// Format time block this session occupies
				long blockStart = cursor.GetLong (SessionsQuery.BLOCK_START);
				long blockEnd = cursor.GetLong (SessionsQuery.BLOCK_END);
				String roomName = cursor.GetString (SessionsQuery.ROOM_NAME);
				String subtitle = UIUtils.FormatSessionSubtitle (blockStart, blockEnd, roomName, Activity);
	
				mTitleString = cursor.GetString (SessionsQuery.TITLE);
				mTitle.Text = mTitleString;
				mSubtitle.Text = subtitle;
	
				mUrl = cursor.GetString (SessionsQuery.URL);
				if (TextUtils.IsEmpty (mUrl)) {
					mUrl = "";
				}
	
				mHashtag = cursor.GetString (SessionsQuery.HASHTAG);
				mTagDisplay = mRootView.FindViewById<TextView> (Resource.Id.session_tags_button);
				if (!TextUtils.IsEmpty (mHashtag)) {
					// Create the button text
					SpannableStringBuilder sb = new SpannableStringBuilder ();
					sb.Append (GetString (Resource.String.tag_stream) + " ");
					int boldStart = sb.Length ();
					sb.Append (GetHashtagsString ());
					sb.SetSpan (sBoldSpan, boldStart, sb.Length (), SpanTypes.ExclusiveExclusive);
	
					mTagDisplay.Text = (string)sb;
					mTagDisplay.Click += (sender, e) => {
						Intent intent = new Intent (Activity, typeof(TagStreamActivity));
						intent.PutExtra (TagStreamFragment.EXTRA_QUERY, GetHashtagsString ());
						StartActivity (intent);	
					};
					
				} else {
					mTagDisplay.Visibility = ViewStates.Gone;
				}
	
				mRoomId = cursor.GetString (SessionsQuery.ROOM_ID);
	
				// Unregister around setting checked state to avoid triggering
				// listener since change isn't user generated.
				mStarred.CheckedChange += null;
				mStarred.Checked = cursor.GetInt (SessionsQuery.STARRED) != 0;
				mStarred.CheckedChange += HandleCheckedChange;
	
				String sessionAbstract = cursor.GetString (SessionsQuery.ABSTRACT);
				if (!TextUtils.IsEmpty (sessionAbstract)) {
					UIUtils.SetTextMaybeHtml (mAbstract, sessionAbstract);
					mAbstract.Visibility = ViewStates.Visible;
					mHasSummaryContent = true;
				} else {
					mAbstract.Visibility = ViewStates.Gone;
				}
	
				View requirementsBlock = mRootView.FindViewById (Resource.Id.session_requirements_block);
				String sessionRequirements = cursor.GetString (SessionsQuery.REQUIREMENTS);
				if (!TextUtils.IsEmpty (sessionRequirements)) {
					UIUtils.SetTextMaybeHtml (mRequirements, sessionRequirements);
					requirementsBlock.Visibility = ViewStates.Visible;
					mHasSummaryContent = true;
				} else {
					requirementsBlock.Visibility = ViewStates.Gone;
				}
	
				// Show empty message when all data is loaded, and nothing to show
				if (mSpeakersCursor && !mHasSummaryContent) {
					mRootView.FindViewWithTag (Android.Resource.Id.Empty).Visibility = ViewStates.Visible;
				}
	
				//AnalyticsUtils.getInstance(getActivity()).trackPageView("/Sessions/" + mTitleString);
	
				UpdateLinksTab (cursor);
				UpdateNotesTab ();
	
			} finally {
				cursor.Close ();
			}
		}
开发者ID:CHANDAN145,项目名称:monodroid-samples,代码行数:88,代码来源:SessionDetailFragment.cs

示例4: OnQueryComplete

		/**
	     * {@inheritDoc}
	     */
		public void OnQueryComplete (int token, Java.Lang.Object cookie, ICursor cursor)
		{
			if (Activity == null) {
				return;
			}
	
			try {
				if (!cursor.MoveToFirst ()) {
					return;
				}
	
				mNameString = cursor.GetString (VendorsQuery.NAME);
				mName.Text = mNameString;
	
				// Unregister around setting checked state to avoid triggering
				// listener since change isn't user generated.
				mStarred.CheckedChange += null;
				mStarred.Checked = cursor.GetInt (VendorsQuery.STARRED) != 0;
				mStarred.CheckedChange += HandleCheckedChange;
	
				// Start background fetch to load vendor logo
				String logoUrl = cursor.GetString (VendorsQuery.LOGO_URL);
	
				if (!TextUtils.IsEmpty (logoUrl)) {
					BitmapUtils.FetchImage (Activity, new Java.Lang.String (logoUrl), null, null, (result) => {
						Activity.RunOnUiThread (() => {
							if (result == null) {
								mLogo.Visibility = ViewStates.Gone;
							} else {
								mLogo.Visibility = ViewStates.Visible;
								mLogo.SetImageBitmap (result);
							}
						});
					});
				}
	
				mUrl.Text = cursor.GetString (VendorsQuery.URL);
				mDesc.Text = cursor.GetString (VendorsQuery.DESC);
				mProductDesc.Text = cursor.GetString (VendorsQuery.PRODUCT_DESC);
	
				mTrackId = cursor.GetString (VendorsQuery.TRACK_ID);
	
				// Assign track details when found
				// TODO: handle vendors not attached to track
				ActivityHelper activityHelper = ((BaseActivity)Activity).ActivityHelper;
				activityHelper.SetActionBarTitle (new Java.Lang.String (cursor.GetString (VendorsQuery.TRACK_NAME)));
				activityHelper.SetActionBarColor (new Color (cursor.GetInt (VendorsQuery.TRACK_COLOR)));
	
				//AnalyticsUtils.getInstance(getActivity()).trackPageView("/Sandbox/Vendors/" + mNameString);
	
			} finally {
				cursor.Close ();
			}
		}
开发者ID:BratislavDimitrov,项目名称:monodroid-samples,代码行数:57,代码来源:VendorDetailFragment.cs

示例5: prepareSyncableNotes

        // syncing based on updated local notes only
        protected void prepareSyncableNotes(ICursor localGuids)
        {
            remoteGuids = new List<string>();
            pushableNotes = new List<Note>();
            pullableNotes = new List<Note>();
            comparableNotes = new List<Note[]>();
            deleteableNotes = new List<Note>();
            conflictingNotes = new List<Note[]>();

            localGuids.MoveToFirst();
            do {
                Note note = NoteManager.getNoteByGuid(activity, localGuids.GetString(localGuids.GetColumnIndexOrThrow(Note.GUID)));

                if(!note.getTags().Contains("system:template")) // don't push templates TODO: find out what's wrong with this, if anything
                    pushableNotes.Add(note);
            } while (localGuids.MoveToNext());

            if(cancelled) {
                doCancel();
                return;
            }

            doSyncNotes();
        }
开发者ID:decriptor,项目名称:tomdroid,代码行数:25,代码来源:SyncService.cs

示例6: OnListItemClick

        //When an item of the list is clicked, it reaches to the SQLite database and retrieves the information associated
        protected void OnListItemClick(object sender, Android.Widget.AdapterView.ItemClickEventArgs e)
        {
            selected = cursor.GetString (1);
            Toast.MakeText (this, selected, ToastLength.Short).Show();
            //			var obj = MyList.Adapter.GetItem(e.Position);
            //			var text = obj.ToString ();
            //			//var curs = (ICursor)obj;
            //			//var text = curs.GetString(1); // 'name' is column 1
            //			Android.Widget.Toast.MakeText(this, text, Android.Widget.ToastLength.Short).Show();
            //			System.Console.WriteLine("Clicked on " + text);
            SetContentView (Resource.Layout.Character);

            TextView name = FindViewById<TextView> (Resource.Id.Name);
            TextView description = FindViewById<TextView> (Resource.Id.Description);
            ImageView picture = FindViewById<ImageView> (Resource.Id.Picture);

            //SQL commands to retrieve information regarding the clicked item from the list
            cursor = vdb.ReadableDatabase.RawQuery("SELECT name FROM superheroes WHERE name = '" + selected + "'", null);
            cursor.MoveToFirst (); //Edited based on suggestion from SAM
            string strName = cursor.GetString(cursor.GetColumnIndex("name"));
            name.Text = strName;
            cursor = vdb.ReadableDatabase.RawQuery("SELECT description FROM superheroes WHERE name = '" + selected + "'", null);
            cursor.MoveToFirst (); //Edited based on suggestion from SAM
            strName = cursor.GetString(cursor.GetColumnIndex("description"));
            description.Text = strName;

            //Cleaning the selected string to get the matching image for the selected character
            selected = selected.Replace (" ", "");
            selected = selected.Replace ("-", "");
            String uri = "drawable/" + selected;
            //Toast.MakeText (this, uri, ToastLength.Short).Show();
            int imageResource = 0;
            imageResource= (int)typeof(Resource.Drawable).GetField(selected).GetValue(null);
            //int imageResource = Resources.GetIdentifier (uri, null, PackageName);
            //Toast.MakeText (this, imageResource.ToString(), ToastLength.Short).Show();
            Android.Graphics.Drawables.Drawable res = Resources.GetDrawable (imageResource);
            //int drawableID = Resources.GetInteger(Resources.GetIdentifier(selected, "drawable", PackageName));
            picture.SetImageDrawable (res);

            //Clicking the picture will go back to the main menu
            picture.Click += delegate {
                // Set our view from the "main" layout resource
                SetContentView (Resource.Layout.Main);

                MyList = FindViewById<ListView> (Resource.Id.myListView);

                // create the cursor
                vdb = new SuperheroesDatabase (this);
                cursor = vdb.ReadableDatabase.RawQuery ("SELECT * FROM Superheroes", null);
                StartManagingCursor (cursor);

                // which columns map to which layout controls
                string[] fromColumns = new string[] { "name" };
                int[] toControlIds = new int [] { Android.Resource.Id.Text1 };

                // use a SimpleCursorAdapter
                MyList.Adapter = new SimpleCursorAdapter (this, Android.Resource.Layout.SimpleListItem1, cursor, fromColumns, toControlIds);

                MyList.ItemClick += OnListItemClick;

            };

            ImageButton Menu;
            Menu = FindViewById<ImageButton> (Resource.Id.imageButton1);
            Menu.Click += delegate {
                // Set our view from the "main" layout resource
                SetContentView (Resource.Layout.Main);

                MyList = FindViewById<ListView> (Resource.Id.myListView);

                // create the cursor
                vdb = new SuperheroesDatabase (this);
                cursor = vdb.ReadableDatabase.RawQuery ("SELECT * FROM Superheroes", null);
                StartManagingCursor (cursor);

                // which columns map to which layout controls
                string[] fromColumns = new string[] { "name" };
                int[] toControlIds = new int [] { Android.Resource.Id.Text1 };

                // use a SimpleCursorAdapter
                MyList.Adapter = new SimpleCursorAdapter (this, Android.Resource.Layout.SimpleListItem1, cursor, fromColumns, toControlIds);

                MyList.ItemClick += OnListItemClick;

            };

            Button Back;
            Back = FindViewById<Button> (Resource.Id.btnMenu);
            Back.Click += delegate {
                // Set our view from the "main" layout resource
                SetContentView (Resource.Layout.Main);

                MyList = FindViewById<ListView> (Resource.Id.myListView);

                // create the cursor
                vdb = new SuperheroesDatabase(this);
                cursor = vdb.ReadableDatabase.RawQuery("SELECT * FROM Superheroes", null);
                StartManagingCursor(cursor);

//.........这里部分代码省略.........
开发者ID:RomeroAlesander,项目名称:DC-Encyclopedia-Android,代码行数:101,代码来源:Characters.cs

示例7: OnQueryComplete

		public void OnQueryComplete (int token, Java.Lang.Object cookie, ICursor cursor)
		{
			if (Activity == null || cursor == null) {
				return;
			}

			mCursor = cursor;
			Activity.StartManagingCursor (mCursor);

			// If there was a last-opened track, load it. Otherwise load the first track.
			cursor.MoveToFirst ();
			String lastTrackID = UIUtils.GetLastUsedTrackID (Activity);
			if (lastTrackID != null) {
				while (!cursor.IsAfterLast) {
					if (lastTrackID.Equals (cursor.GetString (TracksAdapter.TracksQuery.TRACK_ID))) {
						break;
					}
					cursor.MoveToNext ();
				}

				if (cursor.IsAfterLast) {
					LoadTrack (null, mAutoloadTarget);
				} else {
					LoadTrack (cursor, mAutoloadTarget);
				}
			} else {
				LoadTrack (null, mAutoloadTarget);
			}

			mAdapter.SetHasAllItem (true);
			mAdapter.SetIsSessions (TracksFragment.NEXT_TYPE_SESSIONS.Equals (mNextType));
			mAdapter.ChangeCursor (mCursor);
		}
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:33,代码来源:TracksDropdownFragment.cs

示例8: OnTrackQueryComplete

		/**
	     * Handle {@link TracksQuery} {@link Cursor}.
	     */
		private void OnTrackQueryComplete (ICursor cursor)
		{
			try {
				if (!cursor.MoveToFirst ()) {
					return;
				}
	
				// Use found track to build title-bar
				ActivityHelper activityHelper = ((BaseActivity)Activity).ActivityHelper;
				String trackName = cursor.GetString (TracksQuery.TRACK_NAME);
				activityHelper.SetActionBarTitle (new Java.Lang.String (trackName));
				activityHelper.SetActionBarColor (new Color (cursor.GetInt (TracksQuery.TRACK_COLOR)));
				//AnalyticsUtils.getInstance(getActivity()).trackPageView("/Tracks/" + trackName);
			} finally {
				cursor.Close ();
			}
		}
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:20,代码来源:SessionsFragment.cs

示例9: testBulkInsert

        public void testBulkInsert()
        {
            // first, let's create a location value
            ContentValues testValues = TestUtilitiesOpen.createNorthPoleLocationValues ();
            Android.Net.Uri locationUri = context.ContentResolver.Insert (WeatherContractOpen.LocationEntryOpen.CONTENT_URI, testValues);
            long locationRowId = ContentUris.ParseId (locationUri);

            // Verify we got a row back.
            Assert.IsTrue (locationRowId != -1);

            // Data's inserted.  IN THEORY.  Now pull some out to stare at it and verify it made
            // the round trip.

            // A cursor is your primary interface to the Query results.
            cursor = context.ContentResolver.Query (
                WeatherContractOpen.LocationEntryOpen.CONTENT_URI,
                null, // leaving "columns" null just returns all the columns.
                null, // cols for "where" clause
                null, // values for "where" clause
                null  // sort order
            );

            Assert.IsTrue (cursor.MoveToFirst (), "Cursor is empty");
            TestUtilitiesOpen.validateCurrentRecord ("testBulkInsert. Error validating WeatherContractOpen.LocationEntryOpen.",
                cursor, testValues);

            // Now we can bulkInsert some weather.  In fact, we only implement BulkInsert for weather
            // entries.  With ContentProviders, you really only have to implement the features you
            // use, after all.
            ContentValues[] bulkInsertContentValues = createBulkInsertWeatherValues (locationRowId);

            // Register a content observer for our bulk insert.
            TestUtilitiesOpen.TestContentObserver weatherObserver = TestUtilitiesOpen.getTestContentObserver ();
            context.ContentResolver.RegisterContentObserver (WeatherContractOpen.WeatherEntryOpen.CONTENT_URI, true, weatherObserver);

            int insertCount = context.ContentResolver.BulkInsert (WeatherContractOpen.WeatherEntryOpen.CONTENT_URI, bulkInsertContentValues);

            // Students:  If this fails, it means that you most-likely are not calling the
            // getContext().ContentResolver.notifyChange(uri, null); in your BulkInsert
            // ContentProvider method.
            weatherObserver.waitForNotificationOrFail ();
            context.ContentResolver.UnregisterContentObserver (weatherObserver);

            Assert.AreEqual (insertCount, BULK_INSERT_RECORDS_TO_INSERT);

            // A cursor is your primary interface to the Query results.
            cursor = context.ContentResolver.Query (
                WeatherContractOpen.WeatherEntryOpen.CONTENT_URI,
                null, // leaving "columns" null just returns all the columns.
                null, // cols for "where" clause
                null, // values for "where" clause
                WeatherContractOpen.WeatherEntryOpen.COLUMN_DATE + " ASC"  // sort order == by DATE ASCENDING
            );

            // we should have as many records in the database as we've inserted
            Assert.AreEqual (cursor.Count, BULK_INSERT_RECORDS_TO_INSERT);

            // and let's make sure they match the ones we created
            cursor.MoveToFirst ();
            for (int i = 0; i < BULK_INSERT_RECORDS_TO_INSERT; i++, cursor.MoveToNext ()) {
                TestUtilitiesOpen.validateCurrentRecord ("testBulkInsert.  Error validating WeatherContractOpen.WeatherEntryOpen " + i,
                    cursor, bulkInsertContentValues [i]);
            }
            cursor.Close ();
        }
开发者ID:Screech129,项目名称:WeatherApp,代码行数:65,代码来源:TestProvider.cs


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