/**
             * Handler inserting new data.
             */
            public override Uri Insert(Uri uri, Android_Content.ContentValues initialValues)
            {
                if (mUriMatcher.Match(uri) != MAIN) {
                    // Can only insert into to main URI.
                    throw new System.ArgumentException("Unknown URI " + uri);
                }

                Android_Content.ContentValues values;

                if (initialValues != null) {
                    values = new Android_Content.ContentValues(initialValues);
                } else {
                    values = new Android_Content.ContentValues();
                }

                if (values.ContainsKey(MainTable.COLUMN_NAME_DATA) == false) {
                    values.Put(MainTable.COLUMN_NAME_DATA, "");
                }

                SQLiteDatabase db = mOpenHelper.GetWritableDatabase();

                long rowId = db.Insert(MainTable.TABLE_NAME, null, values);

                // If the insert succeeded, the row ID exists.
                if (rowId > 0) {
                    Uri noteUri = Android_Content.ContentUris.WithAppendedId(MainTable.CONTENT_ID_URI_BASE, rowId);
                    GetContext().GetContentResolver().NotifyChange(noteUri, null);
                    return noteUri;
                }

                throw new SQLException("Failed to insert row into " + uri);
            }
        private bool addGroup()
        {
            bool result = false;
            try {

                string name = FindViewById<EditText>(Resource.Id.edit_group_name).Text;
                string description = FindViewById<EditText>(Resource.Id.edit_group_description).Text;
                string icon = FindViewById<EditText>(Resource.Id.edit_group_icon).Text;

                if (name.Length == 0 || description.Length == 0/* || icon.length() == 0*/)
                {
                    Toast.MakeText(this, "One or more fields are empty", ToastLength.Short).Show();
                    return false;
                }

                ContentValues values = new ContentValues();
                values.Put(YastroidOpenHelper.GROUP_NAME, name);
                values.Put(YastroidOpenHelper.GROUP_DESCRIPTION, description);
                values.Put(YastroidOpenHelper.GROUP_ICON, icon);

                database.Insert(YastroidOpenHelper.GROUP_TABLE_NAME, "null", values);
                database.Close();
                Log.Info("addGroup", name + " group has been added.");
                result = true;
            } catch (Exception e) {
                Log.Error("addGroup", e.Message);
            }
            Toast.MakeText(this, "Group Added", ToastLength.Short).Show();
            return result;
        }
            /**
             * Handle updating data.
             */
            public override int Update(Uri uri, Android_Content.ContentValues values, string where, string[] whereArgs)
            {
                SQLiteDatabase db = mOpenHelper.GetWritableDatabase();
                int count;
                string constWhere;

                switch (mUriMatcher.Match(uri)) {
                    case MAIN:
                        // If URI is main table, update uses incoming where clause and args.
                        count = db.Update(MainTable.TABLE_NAME, values, where, whereArgs);
                        break;

                    case MAIN_ID:
                        // If URI is for a particular row ID, update is based on incoming
                        // data but modified to restrict to the given ID.
                        constWhere = DatabaseUtilsCompat.ConcatenateWhere(
                                IBaseColumnsConstants._ID + " = " + Android_Content.ContentUris.ParseId(uri), where);
                        count = db.Update(MainTable.TABLE_NAME, values, constWhere, whereArgs);
                        break;

                    default:
                        throw new System.ArgumentException("Unknown URI " + uri);
                }

                GetContext().GetContentResolver().NotifyChange(uri, null);

                return count;
            }
        public long addToSystemCal(DateTime dstart, String title, String desc, String loc, int calID)
        {
            ContentResolver contentResolver = Forms.Context.ApplicationContext.ContentResolver;

            ContentValues calEvent = new ContentValues();
            calEvent.Put(CalendarContract.Events.InterfaceConsts.CalendarId, calID);
            calEvent.Put(CalendarContract.Events.InterfaceConsts.Title, title);

            double time = dstart.ToUniversalTime ().Subtract (new DateTime (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;

            DateTime dend = dstart;
            dend.AddHours (2);//default 2 hours long

            double timeend = dend.ToUniversalTime ().Subtract (new DateTime (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;

            //Console.WriteLine ("dst " + time + " eventloc: " + loc);

            calEvent.Put(CalendarContract.Events.InterfaceConsts.Dtstart, time);
            calEvent.Put(CalendarContract.Events.InterfaceConsts.Dtend, timeend);
            //CalendarContract.Events.InterfaceConsts.Id

            calEvent.Put(CalendarContract.Events.InterfaceConsts.Description, desc);
            calEvent.Put(CalendarContract.Events.InterfaceConsts.EventLocation, loc);
            calEvent.Put(CalendarContract.Events.InterfaceConsts.EventTimezone, "Australia/Brisbane");//f**k timezones, who even needs them

            long newid = getNewEventId ();
            calEvent.Put(CalendarContract.Events.InterfaceConsts.Id, newid);

            Forms.Context.ApplicationContext.ContentResolver.Insert(CalendarContract.Events.ContentUri, calEvent);

            return newid;
            //Console.WriteLine ("EVENT ADDED TO PHONE MAYBE");
        }
Exemple #5
0
        public override void OnReceive(Context context, Intent intent)
        {
            PowerManager pm = (PowerManager)context.GetSystemService(Context.PowerService);
            PowerManager.WakeLock w1 = pm.NewWakeLock (WakeLockFlags.Full | WakeLockFlags.AcquireCausesWakeup | WakeLockFlags.OnAfterRelease, "NotificationReceiver");
            w1.Acquire ();

            //Toast.MakeText (context, "Received intent!", ToastLength.Short).Show ();
            var nMgr = (NotificationManager)context.GetSystemService (Context.NotificationService);
            //var notification = new Notification (Resource.Drawable.Icon, context.Resources.GetString(Resource.String.ReminderTitle));
            var notification = new Notification (Resource.Drawable.Icon, context.Resources.GetString(Resource.String.ReminderTitle));
            //Clicking the pending intent does not go to the Home Activity Screen, but to the last activity that was active before leaving the app
            var pendingIntent = PendingIntent.GetActivity (context, 0, new Intent (context, typeof(Home)), PendingIntentFlags.UpdateCurrent);
            //Notification should be language specific
            notification.SetLatestEventInfo (context, context.Resources.GetString(Resource.String.ReminderTitle), context.Resources.GetString(Resource.String.InvalidationText), pendingIntent);
            notification.Flags |= NotificationFlags.AutoCancel;
            nMgr.Notify (0, notification);

            //			Vibrator vibrator = (Vibrator) context.GetSystemService(Context.VibratorService);
            //			if (vibrator != null)
            //				vibrator.Vibrate(400);

            //change shared preferences such that the questionnaire button can change its availability
            ISharedPreferences sharedPref = context.GetSharedPreferences("com.FSoft.are_u_ok.PREFERENCES",FileCreationMode.Private);
            ISharedPreferencesEditor editor = sharedPref.Edit();
            editor.PutBoolean("QuestionnaireActive", false );
            editor.Commit ();

            //insert a line of -1 into some DB values to indicate that the questions have not been answered at the scheduled time
            MoodDatabase dbMood = new MoodDatabase(context);
            ContentValues insertValues = new ContentValues();
            insertValues.Put("date", DateTime.Now.ToString("dd.MM.yy"));
            insertValues.Put("time", DateTime.Now.ToString("HH:mm"));
            insertValues.Put("mood", -1);
            insertValues.Put("people", -1);
            insertValues.Put("what", -1);
            insertValues.Put("location", -1);
            //use the old value of questionFlags
            Android.Database.ICursor cursor;
            cursor = dbMood.ReadableDatabase.RawQuery("SELECT date, QuestionFlags FROM MoodData WHERE date = '" + DateTime.Now.ToString("dd.MM.yy") + "'", null); // cursor query
            int alreadyAsked = 0; //default value: no questions have been asked yet
            if (cursor.Count > 0) { //data was already saved today and questions have been asked, so retrieve which ones have been asked
                cursor.MoveToLast (); //take the last entry of today
                alreadyAsked = cursor.GetInt(cursor.GetColumnIndex("QuestionFlags")); //retrieve value from last entry in db column QuestionFlags
            }
            insertValues.Put("QuestionFlags", alreadyAsked);
            dbMood.WritableDatabase.Insert ("MoodData", null, insertValues);

            //set the new alarm
            AlarmReceiverQuestionnaire temp = new AlarmReceiverQuestionnaire();
            temp.SetAlarm(context);

            w1.Release ();

            //check these pages for really waking up the device
            // http://stackoverflow.com/questions/6864712/android-alarmmanager-not-waking-phone-up
            // https://forums.xamarin.com/discussion/7490/alarm-manager

            //it's good to use the alarm manager for tasks that should last even days:
            // http://stackoverflow.com/questions/14376470/scheduling-recurring-task-in-android/
        }
        //android.permission.WRITE_CALENDAR


        public void AddAppointment(DateTime startTime, DateTime endTime, String subject, String location, String details, Boolean isAllDay, AppointmentReminder reminder, AppointmentStatus status)
        {
            ContentValues eventValues = new ContentValues();

            eventValues.Put(CalendarContract.Events.InterfaceConsts.CalendarId, 1);
            //_calId);
            eventValues.Put(CalendarContract.Events.InterfaceConsts.Title, subject);
            eventValues.Put(CalendarContract.Events.InterfaceConsts.Description, details);
            eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtstart, startTime.ToUniversalTime().ToString());
            // GetDateTimeMS(2011, 12, 15, 10, 0));
            eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtend, endTime.ToUniversalTime().ToString());
            // GetDateTimeMS(2011, 12, 15, 11, 0));
            eventValues.Put(CalendarContract.Events.InterfaceConsts.EventTimezone, "UTC");
            eventValues.Put(CalendarContract.Events.InterfaceConsts.EventEndTimezone, "UTC");
            eventValues.Put(CalendarContract.Events.InterfaceConsts.Availability, ConvertAppointmentStatus(status));
            eventValues.Put(CalendarContract.Events.InterfaceConsts.EventLocation, location);
            eventValues.Put(CalendarContract.Events.InterfaceConsts.AllDay, (isAllDay) ? "1" : "0");
            eventValues.Put(CalendarContract.Events.InterfaceConsts.HasAlarm, "1");

            var eventUri = CalendarConnector.Activity.ContentResolver.Insert(CalendarContract.Events.ContentUri, eventValues);
            long eventID = long.Parse(eventUri.LastPathSegment);
            ContentValues remindervalues = new ContentValues();
            remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.Minutes, ConvertReminder(reminder));
            remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.EventId, eventID);
            remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.Method, (int)RemindersMethod.Alert);
            var reminderURI = CalendarConnector.Activity.ContentResolver.Insert(CalendarContract.Reminders.ContentUri, remindervalues);

        }
        void UpdateProfile ()
        {   
            // write to the profile
            var values = new ContentValues ();
            
            values.Put (ContactsContract.Contacts.InterfaceConsts.DisplayName, "John Doe");
            
            ContentResolver.Update (ContactsContract.Profile.ContentRawContactsUri, values, null, null);
            
            // read the profile
            var uri = ContactsContract.Profile.ContentUri;
            
            string[] projection = { 
                ContactsContract.Contacts.InterfaceConsts.DisplayName };
            
            var cursor = ManagedQuery (uri, projection, null, null, null);

            if (cursor.MoveToFirst ()) {
                Console.WriteLine(cursor.GetString (cursor.GetColumnIndex (projection [0])));
            }
            
            // navigate to the profile in the people app
            var intent = new Intent (Intent.ActionView, ContactsContract.Profile.ContentUri);            
            StartActivity (intent);    
        }
        public override void OnProgressChanged(WebView view, int newProgress)
        {
            base.OnProgressChanged(view, newProgress);

            _context.SetProgress(newProgress * 100);

            if (newProgress == 100)
            {
                _context.Title = view.Title;

                bool soundEnabled = PreferenceManager.GetDefaultSharedPreferences(_context.ApplicationContext).GetBoolean("sounds", false);

                if (soundEnabled)
                {
                    _mediaPlayer = MediaPlayer.Create(_context.ApplicationContext, Resource.Raw.inception_horn);
                    _mediaPlayer.Completion += delegate { _mediaPlayer.Release(); };
                    _mediaPlayer.Start();
                }

                // add this page to the history
                using (SQLiteDatabase db = _historyDataHelper.WritableDatabase)
                {
                    var values = new ContentValues();
                    values.Put("Title", view.Title);
                    values.Put("Url", view.Url);
                    values.Put("Timestamp", DateTime.Now.Ticks);

                    db.Insert("history", null, values);
                }
            }
            else
            {
                _context.Title = _context.ApplicationContext.Resources.GetString(Resource.String.title_loading);
            }
        }
Exemple #9
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Create your application here
            SetContentView (Resource.Layout.QuestionnaireSummary);
            int Ergebnis = Intent.GetIntExtra ("ergebnis", 0);

            TextView ErgebnisText = FindViewById<TextView> (Resource.Id.textView3);
            ErgebnisText.Text = string.Format ("{0} {1}", Resources.GetText (Resource.String.total_score), Ergebnis);

            Button ContinueHome = FindViewById<Button> (Resource.Id.button1);
            ContinueHome.Click += delegate {
                //create an intent to go to the next screen
                Intent intent = new Intent(this, typeof(Home));
                intent.SetFlags(ActivityFlags.ClearTop); //remove the history and go back to home screen
                StartActivity(intent);
            };

            //Toast.MakeText (this, string.Format ("{0}", DateTime.Now.ToString("dd.MM.yy HH:mm")), ToastLength.Short).Show();

            ContentValues insertValues = new ContentValues();
            insertValues.Put("date_time", DateTime.Now.ToString("dd.MM.yy HH:mm"));
            insertValues.Put("ergebnis", Ergebnis);
            dbRUOK = new RUOKDatabase(this);
            dbRUOK.WritableDatabase.Insert ("RUOKData", null, insertValues);

            //The following two function were used to understand the usage of SQLite. They are not needed anymore and I just keep them in case I wanna later look back at them.
            //InitializeSQLite3(Ergebnis);
            //ReadOutDB ();
        }
        public override void PerformAction(View view)
        {
            try
            {
                ContentValues eventValues = new ContentValues();

                eventValues.Put( CalendarContract.Events.InterfaceConsts.CalendarId,
                    _calId);
                eventValues.Put(CalendarContract.Events.InterfaceConsts.Title,
                    "Test Event from M4A");
                eventValues.Put(CalendarContract.Events.InterfaceConsts.Description,
                    "This is an event created from Xamarin.Android");
                eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtstart,
                    GetDateTimeMS(2011, 12, 15, 10, 0));
                eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtend,
                    GetDateTimeMS(2011, 12, 15, 11, 0));

                var uri = ContentResolver.Insert(CalendarContract.Events.ContentUri,
                    eventValues);
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.Android, Context);

            }
        }
        public long AddTweet(Tweet tweet)
        {
            var values = new ContentValues ();
            values.Put ("Source", tweet.SourceString);

            return twtHelp.WritableDatabase.Insert ("Tweet", null, values);
        }
    private void SharePhoto()
    {
      var share = new Intent(Intent.ActionSend);
      share.SetType("image/jpeg");

      var values = new ContentValues();
      values.Put(MediaStore.Images.ImageColumns.Title, "title");
      values.Put(MediaStore.Images.ImageColumns.MimeType, "image/jpeg");
      Uri uri = ContentResolver.Insert(MediaStore.Images.Media.ExternalContentUri, values);


      Stream outstream;
      try
      {
        
        outstream = ContentResolver.OpenOutputStream(uri);
        finalBitmap.Compress(Bitmap.CompressFormat.Jpeg, 100, outstream);
        outstream.Close();
      }
      catch (Exception e)
      {

      }
      share.PutExtra(Intent.ExtraStream, uri);
      share.PutExtra(Intent.ExtraText, "Sharing some images from android!");
      StartActivity(Intent.CreateChooser(share, "Share Image"));
    }
 public void UpdateStockItems(List<StockDataItem> stockDataItems)
 {
     var stockItemsCsv = string.Join(",", stockDataItems.Select(i => ((int) i).ToString()).ToArray());
     var contentValues = new ContentValues();
     contentValues.Put("StockItems", stockItemsCsv);
     Db.Update(CONFIG_TABLE_NAME, contentValues, null, null);
 }
        public override void OnCreate(SQLiteDatabase paramSQLiteDatabase)
        {
            // Create table "wikinotes"
            paramSQLiteDatabase.ExecSQL("CREATE TABLE " + WikiNote.Notes.TABLE_WIKINOTES + " (" + WikiNote.Notes.Id + " INTEGER PRIMARY KEY,"
                + WikiNote.Notes.TITLE + " TEXT COLLATE LOCALIZED NOT NULL,"
                + WikiNote.Notes.BODY + " TEXT,"
                + WikiNote.Notes.CREATED_DATE + " INTEGER,"
                + WikiNote.Notes.MODIFIED_DATE + " INTEGER" + ");");

            // Initialize database
            ContentValues localContentValues = new ContentValues();
            localContentValues.Put(WikiNote.Notes.TITLE, this._context.Resources.GetString(Resource.String.start_page));
            localContentValues.Put(WikiNote.Notes.BODY, this._context.Resources.GetString(Resource.String.top_note));
            long localLong = DateTime.Now.ToFileTimeUtc();
            localContentValues.Put(WikiNote.Notes.CREATED_DATE, localLong);
            localContentValues.Put(WikiNote.Notes.MODIFIED_DATE, localLong);

            paramSQLiteDatabase.Insert(WikiNote.Notes.TABLE_WIKINOTES, "huh?", localContentValues);

            localContentValues.Put(WikiNote.Notes.TITLE, "PageFormatting");
            localContentValues.Put(WikiNote.Notes.BODY, this._context.Resources.GetString(Resource.String.page_formatting_note));
            localContentValues.Put(WikiNote.Notes.CREATED_DATE, localLong);
            localContentValues.Put(WikiNote.Notes.MODIFIED_DATE, localLong);

            paramSQLiteDatabase.Insert(WikiNote.Notes.TABLE_WIKINOTES, "huh?", localContentValues);
        }
        /// <summary>
        /// Create a new note using the title and body provided. If the note is
        /// successfully created return the new rowId for that note, otherwise return
        /// a -1 to indicate failure.
        /// </summary>
        /// <param name="title">the title of the note</param>
        /// <param name="body">the body of the note</param>
        /// <returns>rowId or -1 if failed</returns>
        public long CreateNote(string title, string body)
        {
            var initialValues = new ContentValues();
            initialValues.Put(KeyTitle, title);
            initialValues.Put(KeyBody, body);

            return this.db.Insert(DatabaseTable, null, initialValues);
        }
        public long AddNote(string title, string contents)
        {
            var values = new ContentValues();
            values.Put("Title", title);
            values.Put("Contents", contents);

            return _helper.WritableDatabase.Insert("Note", null, values);
        }
        public void putRecord(long time, String difficulty, Context context)
        {
            dbHelper = new DBHelper(context);
            ContentValues cv = new ContentValues();
            SQLiteDatabase db = dbHelper.WritableDatabase;
            SQLiteCursor c = (SQLiteCursor)db.Query("records", null, " difficulty = ?", new String[]{difficulty}, null, null, null);
            int count = 1;
            if (c.MoveToFirst()) {

                int idColIndex = c.GetColumnIndex("id");
                int timeColIndex = c.GetColumnIndex("time");

                int maxDBindex = c.GetInt(idColIndex);
                int maxDBtime = c.GetInt(timeColIndex);
                count++;
                while (c.MoveToNext()) {
                    if (c.GetInt(timeColIndex) > maxDBtime){
                        maxDBtime = c.GetInt(timeColIndex);
                        maxDBindex = c.GetInt(idColIndex);
                    }
                    count++;
                }
                if (count == 6){
                    if (time < maxDBtime){
                        db.Delete("records", " id = ?", new String[]{maxDBindex + ""});
                    } else {
                        c.Close();
                        db.Close();
                        return;
                    }
                }
            }
            cv.Put("time", time);
            cv.Put("difficulty", difficulty);
            db.Insert("records", null, cv);
            cv.Clear();

            SQLiteCursor gc = (SQLiteCursor)db.Query("general", null, "difficulty = ?", new String[]{difficulty}, null, null, null);
            gc.MoveToFirst();
            int avgTimeColIndex = gc.GetColumnIndex("avgTime");
            int gamesCountColIndex = gc.GetColumnIndex("gamesCount");
            int avgTime = 0;
            int gamesCount = 0;
            if (gc.MoveToFirst()){
                avgTime = gc.GetInt(avgTimeColIndex);
                gamesCount = gc.GetInt(gamesCountColIndex);
            }
            int newGamesCount = gamesCount + 1;
            int newAvgTime = (avgTime * gamesCount / newGamesCount) + (int)(time / newGamesCount);
            cv.Put("difficulty", difficulty);
            cv.Put("avgTime", newAvgTime);
            cv.Put("gamesCount", newGamesCount);
            db.Delete("general", " difficulty = ?", new String[]{difficulty});
            db.Insert("general", null, cv);
            db.Close();
            c.Close();
            gc.Close();
        }
Exemple #18
0
 public long Update(String oldBattleTag, String battleTag, String host, Action<AccountFields> action)
 {
     var db = dbHelper.WritableDatabase;
     var values = new ContentValues();
     values.Put(AccountsOpenHelper.FIELD_BATTLETAG, battleTag);
     values.Put(AccountsOpenHelper.FIELD_HOST, host);
     values.Put(AccountsOpenHelper.FIELD_UPDATED, DateTime.Today.ToString(CultureInfo.InvariantCulture));
     return db.Update(AccountsOpenHelper.TABLE_NAME, values, AccountsOpenHelper.FIELD_BATTLETAG + "=?", new[] { oldBattleTag });
 }
Exemple #19
0
 public long Insert(String battleTag, String host)
 {
     var db = dbHelper.WritableDatabase;
     var values = new ContentValues();
     values.Put(AccountsOpenHelper.FIELD_BATTLETAG, battleTag);
     values.Put(AccountsOpenHelper.FIELD_HOST, host);
     values.Put(AccountsOpenHelper.FIELD_UPDATED, DateTime.Today.ToString());
     return db.Insert(AccountsOpenHelper.TABLE_NAME, null, values);
 }
Exemple #20
0
        public long AddScore(int scoreNumber, DateTime scoreDate, string name)
        {
            var values = new ContentValues ();
            values.Put ("ScoreNumber", scoreNumber);
            values.Put ("ScoreDate", scoreDate.ToString ());
            values.Put ("PlayerName", name);

            return scrHelp.WritableDatabase.Insert ("QuizScore", null, values);
        }
 public void insert(Transaction transaction)
 {
     ContentValues values = new ContentValues();
     values.Put(COLUMN__ID, transaction.orderId);
     values.Put(COLUMN_PRODUCT_ID, transaction.productId);
     values.Put(COLUMN_STATE, transaction.purchaseState.ToString());
     values.Put(COLUMN_PURCHASE_TIME, transaction.purchaseTime);
     values.Put(COLUMN_DEVELOPER_PAYLOAD, transaction.developerPayload);
     mDb.Replace(TABLE_TRANSACTIONS, null /* nullColumnHack */, values);
 }
        // Give the device user a name: "John Doe"
        void NameOwner()
        {
            // Create the display name for the user's profile:
            ContentValues values = new ContentValues();
            values.Put (ContactsContract.Contacts.InterfaceConsts.DisplayName, "John Doe");

            // Insert the user's name. Note that the user's profile entry cannot be created explicitly
            // (attempting to do so will throw an exception):
            ContentResolver.Update (ContactsContract.Profile.ContentRawContactsUri, values, null, null);
        }
Exemple #23
0
        public long AddScore(int ScoreNumber, DateTime ScoreDate, double rating, double slope)
        {
            var values = new ContentValues();
            values.Put("ScoreNumber", ScoreNumber);
            values.Put("ScoreDate", ScoreDate.ToString());
            values.Put("Rating", rating);
            values.Put("Slope", slope);

            return dbHelp.WritableDatabase.Insert("GolfScore", null, values);
        }
        private Uri GetNewImageUri()
        {
            // Optional - specify some metadata for the picture
            var contentValues = new ContentValues();
            //contentValues.Put(MediaStore.Images.ImageColumnsConsts.Description, "A camera photo");

            // Specify where to put the image
            return
                this.GetService<IMvxAndroidGlobals>()
                    .ApplicationContext.ContentResolver.Insert(MediaStore.Images.Media.ExternalContentUri, contentValues);
        }
Exemple #25
0
        public long AddStation(Station station)
        {
            var values = new ContentValues ();
            values.Put ("ID", station.ID);
            values.Put ("locationX", station.LocationX);
            values.Put ("locationY", station.LocationY);
            values.Put ("name", station.Name);
            values.Put ("standardName", station.StandardName);

            return stationHelp.WritableDatabase.Insert ("Station", null, values);
        }
        public static ContentValues createLocationValues(string locationSetting, string cityName, double lat, double lon)
        {
            // Create a new map of values, where column names are the keys
            ContentValues locValues = new ContentValues ();
            locValues.Put (WeatherContractOpen.LocationEntryOpen.COLUMN_LOCATION_SETTING, locationSetting);
            locValues.Put (WeatherContractOpen.LocationEntryOpen.COLUMN_CITY_NAME, cityName);
            locValues.Put (WeatherContractOpen.LocationEntryOpen.COLUMN_COORD_LAT, lat);
            locValues.Put (WeatherContractOpen.LocationEntryOpen.COLUMN_COORD_LONG, lon);

            return locValues;
        }
        public long AddConnection(Connection connection)
        {
            var values = new ContentValues ();
            var id = connection.Source [0];
            var source = connection.Source [1];
            Console.WriteLine ("{0} - {1}", id, source);
            values.Put ("ID", id);
            values.Put ("SOURCE", source);

            return connectionHelp.WritableDatabase.Insert ("Connection", null, values);
        }
Exemple #28
0
		// Adding new question
		public void addQuestion(Question quest) {
			//SQLiteDatabase db = this.getWritableDatabase();
			ContentValues values = new ContentValues();
			values.Put(KEY_QUES, quest.getQUESTION()); 
			values.Put(KEY_ANSWER, quest.getANSWER());
			values.Put(KEY_OPTA, quest.getOPTA());
			values.Put(KEY_OPTB, quest.getOPTB());
			values.Put(KEY_OPTC, quest.getOPTC());
			// Inserting Row
			dbase.Insert(TABLE_QUEST, null, values);		
		}
        public void BulkInsertWeather(ArrayList weatherValues, string locationSetting)
        {
            _context.ContentResolver.Delete (WeatherContractOpen.WeatherEntryOpen.CONTENT_URI, null, null);
            var insertedCount = 0;
            if (weatherValues.Count > 0) {
                var cvArray = new ContentValues[weatherValues.Count];

                cvArray = (ContentValues[])weatherValues.ToArray (typeof(ContentValues));
                insertedCount = _context.ContentResolver.BulkInsert (WeatherContractOpen.WeatherEntryOpen.CONTENT_URI, cvArray);
            }

            Log.Debug ("Fetch Weather Task", "FetchweatherTask Complete " + insertedCount + " records Inserted");
        }
 public ContentValues ToContentValues()
 {
     var cv = new ContentValues();
     if (Id > 0)
     {
         cv.Put(VehicleTable.Columns.ID, Id);
     }
     cv.Put(VehicleTable.Columns.ROWGUID, RowGuid.ToString());
     cv.Put(VehicleTable.Columns.VEHICLE, Name.Trim());
     cv.Put(VehicleTable.Columns.CREATE_DATE, CreateDate.ToString(Util.DATE_FORMAT));
     cv.Put(VehicleTable.Columns.MODIFICATION_DATE, ModificationDate.ToString(Util.DATE_FORMAT));
     return cv;
 }
		public override void SetBadge(int count) {
			try {
				var contentValues = new ContentValues();
				contentValues.Put("tag", GetPackageName() + "/" + GetMainActivityClassName());
				contentValues.Put("count", count);
				mContext.ContentResolver.Insert(Android.Net.Uri.Parse("content://com.teslacoilsw.notifier/unread_count"), contentValues);
			} catch (Java.Lang.IllegalArgumentException ex) {
				/* Fine, TeslaUnread is not installed. */
			} catch (Exception ex) {
				/* Some other error, possibly because the format of the ContentValues are incorrect. */
				throw new BadgesNotSupportedException(ex.Message);
			}
		}
        public long AddQuestion(string stringForQuestion, DateTime dateEntered)
        {
            string[] stringArrayForQuestion = stringForQuestion.Split ('_');
            var values = new ContentValues ();
            values.Put ("ImageID", Convert.ToInt32 (stringArrayForQuestion[0]));
            values.Put ("QuestionString", stringArrayForQuestion[1]);
            values.Put ("CorrectAnswer", stringArrayForQuestion[2]);
            values.Put ("WrongAnswer1", stringArrayForQuestion[3]);
            values.Put ("WrongAnswer2", stringArrayForQuestion[4]);
            values.Put ("WrongAnswer3", stringArrayForQuestion[5]);
            values.Put ("DateEntered", dateEntered.ToString ());

            return qstHelp.WritableDatabase.Insert ("Question", null, values);
        }
 protected override object DoInBackground(params object[] @params)
 {
     for (char c='Z'; c>='A'; c--) {
         if (IsCancelled()) {
             break;
         }
         StringBuilder builder = new StringBuilder("Data ");
         builder.Append(c);
         Android_Content.ContentValues values = new Android_Content.ContentValues();
         values.Put(MainTable.COLUMN_NAME_DATA, builder.ToString());
         cr.Insert(MainTable.CONTENT_URI, values);
         // Wait a bit between each insert.
         try {
             Thread.Sleep(250);
         } catch (InterruptedException) {
         }
     }
     return null;
 }