public void Savemarker(double lat, double lng)
        {
            ContentValues values = new ContentValues();

            values.Put(MapMarkerContract.MarkerTable.COLUMN_NAME_LAT, lat);
            values.Put(MapMarkerContract.MarkerTable.COLUMN_NAME_LONG, lng);

            WritableDatabase.Insert(MapMarkerContract.MarkerTable.TABLE_NAME, null, values);
        }
示例#2
0
        public bool Save(int medicationSpreadID)
        {
            SQLiteDatabase sqlDatabase = null;

            try
            {
                Globals dbHelp = new Globals();
                dbHelp.OpenDatabase();
                sqlDatabase = dbHelp.GetSQLiteDatabase();
                if (sqlDatabase != null)
                {
                    if (sqlDatabase.IsOpen)
                    {
                        if (IsNew)
                        {
                            Log.Info(TAG, "Save: Saving new Medication Time to Spread ID - " + medicationSpreadID.ToString());
                            ContentValues values = new ContentValues();
                            values.Put("MedicationSpreadID", medicationSpreadID);
                            values.Put("MedicationTime", (int)MedicationTime);
                            values.Put("TakenTime", string.Format("{0:HH:mm:ss}", TakenTime));
                            Log.Info(TAG, "Save: Stored Medication Time - " + StringHelper.MedicationTimeForConstant(MedicationTime) + ", Time Taken - " + TakenTime.ToShortTimeString());
                            ID = (int)sqlDatabase.Insert("MedicationTime", null, values);
                            Log.Info(TAG, "Save: Saved Medication Time with new ID - " + ID.ToString());
                            IsNew   = false;
                            IsDirty = false;
                            Log.Info(TAG, "Save: IsNew - FALSE, IsDirty - FALSE");
                        }
                        if (IsDirty)
                        {
                            Log.Info(TAG, "Save (Update): Updating existing Medication Time for Spread ID - " + medicationSpreadID.ToString());
                            ContentValues values = new ContentValues();
                            values.Put("MedicationSpreadID", medicationSpreadID);
                            values.Put("MedicationTime", (int)MedicationTime);
                            values.Put("TakenTime", string.Format("{0:HH:mm:ss}", TakenTime));
                            Log.Info(TAG, "Save (Update): Stored Medication Time - " + StringHelper.MedicationTimeForConstant(MedicationTime) + ", Taken Time - " + TakenTime.ToShortTimeString());
                            string whereClause = "ID = ?";
                            sqlDatabase.Update("MedicationTime", values, whereClause, new string[] { ID.ToString() });
                            IsDirty = false;
                            Log.Info(TAG, "Save (Update): IsDirty - FALSE");
                        }
                        sqlDatabase.Close();
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception e)
            {
                Log.Error(TAG, "Save: Exception - " + e.Message);
                if (sqlDatabase != null && sqlDatabase.IsOpen)
                {
                    sqlDatabase.Close();
                }
                return(false);
            }
        }
示例#3
0
        //Add New User!!!!!
        public void AddNewUser(User NewUser)
        {
            SQLiteDatabase db   = this.ReadableDatabase;
            ContentValues  vals = new ContentValues();

            vals.Put("UserName", NewUser.UserName);
            vals.Put("Password", NewUser.Password);
            vals.Put("Email", NewUser.Email);
            db.Insert("UserDataBase", null, vals);
        }
示例#4
0
        private ContentValues GetPositionContentValues(Position position)
        {
            var positionValues = new ContentValues();

            positionValues.Put("PricePerShare", (double)position.PricePerShare);
            positionValues.Put("Ticker", position.Ticker.ToUpper());
            positionValues.Put("Shares", (double)position.Shares);
            positionValues.Put("ContainingPortfolioID", position.ContainingPortfolioID);
            return(positionValues);
        }
示例#5
0
        public ContentValues GetContentValues()
        {
            ContentValues value = new ContentValues();

            value.Put(KEY_COLLECTION_ID, CollectionID);
            value.Put(KEY_MOVIE_ID, MovieID);
            value.Put(KEY_MOVIE_TITLE, MovieTitle);

            return(value);
        }
示例#6
0
        private void InsertIntoLove(string number, string type)
        {
            DBHelper       dbNew         = new DBHelper(this, "LoveDB.db");
            SQLiteDatabase sqlitedb      = dbNew.WritableDatabase;;
            ContentValues  contentValues = new ContentValues();

            contentValues.Put("number", number);
            contentValues.Put("type", type);
            sqlitedb.Insert("Love", null, contentValues);
        }
示例#7
0
 public long InsertLinkTable(string childId, string eventID, string currentPaid)
 {
     SQLiteDatabase db = helper.WritableDatabase;
     ContentValues contentValues = new ContentValues();
     contentValues.Put(DBHelper.LINK_CHILD_ID, childId);
     contentValues.Put(DBHelper.LINK_EVENT_ID, eventID);
     contentValues.Put(DBHelper.LINK_CURRENT_PAID, currentPaid);
     long id = db.Insert(DBHelper.CHLD_TO_EVENT_LINK_TABLE_NAME, null, contentValues);
     return id;
 }
示例#8
0
 public long InsertEvent(string name, string price, string time)
 {
     SQLiteDatabase db = helper.WritableDatabase;
     ContentValues contentValues = new ContentValues();
     contentValues.Put(DBHelper.EVENT_NAME, name);
     contentValues.Put(DBHelper.EVENT_PRICE, price);
     contentValues.Put(DBHelper.EVENT_DATE, time);
     long id = db.Insert(DBHelper.EVENT_TABLE_NAME, null, contentValues);
     return id;
 }
        public void InsertNewTask(String task, String date)
        {
            SQLiteDatabase db     = this.WritableDatabase;
            ContentValues  values = new ContentValues();

            values.Put("TaskName", task);
            values.Put("TaskDate", date);
            db.InsertWithOnConflict(DB_TABLE, null, values, Android.Database.Sqlite.Conflict.Replace);
            db.Close();
        }
示例#10
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));
        }
示例#11
0
            public void initDB(SQLiteDatabase db)
            {
                db.ExecSQL("DROP TABLE IF EXISTS " + "general");
                db.ExecSQL("DROP TABLE IF EXISTS " + "records");
                db.ExecSQL("create table records ("
                           + "id integer primary key autoincrement,"
                           + "time int,"
                           + "difficulty text" + ");");
                db.ExecSQL("create table general ("
                           + "difficulty text primary key,"
                           + "avgTime int,"
                           + "gamesCount int" + ");");
                ContentValues cv = new ContentValues();

                cv.Put("difficulty", "Easy");
                cv.Put("avgTime", 0);
                cv.Put("gamesCount", 0);
                db.Insert("general", null, cv);
                cv.Clear();
                cv.Put("difficulty", "Normal");
                cv.Put("avgTime", 0);
                cv.Put("gamesCount", 0);
                db.Insert("general", null, cv);
                cv.Clear();
                cv.Put("difficulty", "Hard");
                cv.Put("avgTime", 0);
                cv.Put("gamesCount", 0);
                db.Insert("general", null, cv);
            }
示例#12
0
        public bool SetMapReduce(Mapper mapBlock, Reducer reduceBlock, string version)
        {
            System.Diagnostics.Debug.Assert((mapBlock != null));
            System.Diagnostics.Debug.Assert((version != null));
            this.mapBlock    = mapBlock;
            this.reduceBlock = reduceBlock;
            if (!database.Open())
            {
                return(false);
            }
            // Update the version column in the database. This is a little weird looking
            // because we want to
            // avoid modifying the database if the version didn't change, and because the
            // row might not exist yet.
            SQLiteStorageEngine storageEngine = this.database.GetDatabase();
            // Older Android doesnt have reliable insert or ignore, will to 2 step
            // FIXME review need for change to execSQL, manual call to changes()
            string sql = "SELECT name, version FROM views WHERE name=?";

            string[] args   = new string[] { name };
            Cursor   cursor = null;

            try
            {
                cursor = storageEngine.RawQuery(sql, args);
                if (!cursor.MoveToNext())
                {
                    // no such record, so insert
                    ContentValues insertValues = new ContentValues();
                    insertValues.Put("name", name);
                    insertValues.Put("version", version);
                    storageEngine.Insert("views", null, insertValues);
                    return(true);
                }
                ContentValues updateValues = new ContentValues();
                updateValues.Put("version", version);
                updateValues.Put("lastSequence", 0);
                string[] whereArgs    = new string[] { name, version };
                int      rowsAffected = storageEngine.Update("views", updateValues, "name=? AND version!=?"
                                                             , whereArgs);
                return(rowsAffected > 0);
            }
            catch (SQLException e)
            {
                Log.E(Log.TagView, "Error setting map block", e);
                return(false);
            }
            finally
            {
                if (cursor != null)
                {
                    cursor.Close();
                }
            }
        }
示例#13
0
        /// <summary>
        /// Inserts a purchased product into the database. There may be multiple
        /// rows in the table for the same product if it was purchased multiple times
        /// or if it was refunded. </summary>
        /// <param name="orderId"> the order ID (matches the value in the product list) </param>
        /// <param name="productId"> the product ID (sku) </param>
        /// <param name="state"> the state of the purchase </param>
        /// <param name="purchaseTime"> the purchase time (in milliseconds since the epoch) </param>
        /// <param name="developerPayload"> the developer provided "payload" associated with
        ///     the order. </param>
        private void insertOrder(string orderId, string productId, PurchaseState state, long purchaseTime, string developerPayload)
        {
            ContentValues values = new ContentValues();

            values.Put(HISTORY_ORDER_ID_COL, orderId);
            values.Put(HISTORY_PRODUCT_ID_COL, productId);
            values.Put(HISTORY_STATE_COL, state.ToString());
            values.Put(HISTORY_PURCHASE_TIME_COL, purchaseTime);
            values.Put(HISTORY_DEVELOPER_PAYLOAD_COL, developerPayload);
            mDb.Replace(PURCHASE_HISTORY_TABLE_NAME, null, values); // nullColumnHack
        }
示例#14
0
        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);
        }
示例#15
0
        }         // GetAllScores

        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));
        }         // AddScore
        //Add New Contact
        public void AddNewContact(AddressBook contactinfo)
        {
            SQLiteDatabase db   = this.WritableDatabase;
            ContentValues  vals = new ContentValues();

            vals.Put("FullName", contactinfo.FullName);
            vals.Put("Mobile", contactinfo.Mobile);
            vals.Put("Email", contactinfo.Email);
            vals.Put("Details", contactinfo.Details);
            db.Insert("AddressBook", null, vals);
        }
示例#17
0
 public override void OnCreate(SQLiteDatabase db)
 {
     db.ExecSQL(TABLE_CREATE);
     foreach (Template template in DEFAULT_TEMPLATES)
     {
         ContentValues c = new ContentValues();
         c.Put(KEY_NAME, template.Name);
         c.Put(KEY_VALUE, template.Value);
         db.InsertOrThrow(TABLE_NAME, null, c);
     }
 }
示例#18
0
            public static void InsertPerson(Context context, Person person)
            {
                SQLiteDatabase db            = new DataStore(context).WritableDatabase;
                ContentValues  contentValues = new ContentValues();

                contentValues.Put(ColumnName, person.Name);
                contentValues.Put(ColumnDob, person.Dob.ToString());

                db.Insert(TableName, null, contentValues);
                db.Close();
            }
示例#19
0
        //Add New Contact
        public void AddNewUser(User userinfo)
        {
            SQLiteDatabase db   = this.WritableDatabase;
            ContentValues  vals = new ContentValues();

            vals.Put("Firstname", userinfo.Firstname);
            vals.Put("Lastname", userinfo.Lastname);
            vals.Put("Address", userinfo.Address);
            vals.Put("Email", userinfo.Email);
            db.Insert("User", null, vals);
        }
示例#20
0
        public ContentValues GetContentValues()
        {
            ContentValues value = new ContentValues();

            value.Put(KEY_USERNAME, Username);
            value.Put(KEY_PASSWORD, Password);
            value.Put(KEY_DISPLAYNAME, DisplayName);
            value.Put(KEY_EMAIL, Email);

            return(value);
        }
示例#21
0
        public void insercat(Context context, catpojo c)
        {
            SQLiteDatabase db            = new DataStore(context).WritableDatabase;
            ContentValues  contentValues = new ContentValues();

            contentValues.Put(SubcatID, c.Subid);
            contentValues.Put(ColumnName, c.Name);

            db.Insert(TableName, null, contentValues);
            db.Close();
        }
示例#22
0
        public void InsertProductInfo(string title, string type, string cost, string quantity)
        {
            var contentData = new ContentValues();

            contentData.Put(titleField, title);
            contentData.Put(typeField, type);
            contentData.Put(costField, cost);
            contentData.Put(quantityField, quantity);

            this.dbObj.Insert(TableName, null, contentData);
        }
示例#23
0
            public static void UpdatePerson(Context context, Person person)
            {
                SQLiteDatabase db            = new DataStore(context).WritableDatabase;
                ContentValues  contentValues = new ContentValues();

                contentValues.Put(ColumnName, person.Name);
                contentValues.Put(ColumnDob, person.Dob.ToString());

                db.Update(TableName, contentValues, ColumnID + "=?", new string[] { person.Id.ToString() });
                db.Close();
            }
        private void SaveImageToGallery(string path)
        {
            var values = new ContentValues();

            values.Put(MediaStore.Images.ImageColumns.DateTaken, Java.Lang.JavaSystem.CurrentTimeMillis());
            values.Put(MediaStore.Images.ImageColumns.MimeType, "image/jpeg");
            values.Put(MediaStore.MediaColumns.Data, path);

            CrossCurrentActivity.Current.Activity.ContentResolver.Insert(
                MediaStore.Images.Media.ExternalContentUri,
                values);
        }
示例#25
0
        public ContentValues updateEntry(column _column)
        {
            ContentValues values = new ContentValues();

            values.Put("gId", _column.globalId_);
            values.Put("Name", _column.name_);
            values.Put("Time", _column.time_);
            values.Put("Text", _column.text_);
            values.Put("Enabled", _column.enabled_);

            return(values);
        }
示例#26
0
        public void inserscore(Context context, string name, string score)
        {
            SQLiteDatabase db            = new DataStore(context).WritableDatabase;
            ContentValues  contentValues = new ContentValues();

            contentValues.Put("name", name);
            contentValues.Put("score", score);

            db.Insert("score1", null, contentValues);
            // Toast.MakeText(context, "insert" , ToastLength.Long).Show();
            db.Close();
        }
示例#27
0
        private ContentValues GetContentValues(ComponentName componentName, int badgeCount, bool isInsert)
        {
            var contentValues = new ContentValues();

            if (isInsert)
            {
                contentValues.Put("package", componentName.PackageName);
                contentValues.Put("class", componentName.ClassName);
            }
            contentValues.Put("badgecount", badgeCount);
            return(contentValues);
        }
示例#28
0
        public void SaveBitmapBase(long id, string path, int start, int end, Bitmap image) //SAVE IMAGE IN DB
        {
            byte[]        bytearray = Multitools.ConvertoBLob(image);
            ContentValues cv        = new ContentValues();

            cv.Put(COLUMN_ID, id);
            cv.Put(COLUMN_IMGPATH, path);
            cv.Put(COLUMN_START, start);
            cv.Put(COLUMN_END, end);
            cv.Put(COLUMN_BITMAP, bytearray);
            WritableDatabase.Insert(CONTENTTABLE, null, cv);
        }
示例#29
0
        public static void InsertReminderData(Context context, Reminder reminder)
        {
            SQLiteDatabase db            = new DataStore(context).WritableDatabase;
            ContentValues  contentValues = new ContentValues();

            contentValues.Put(ColumnDate, reminder.Date);
            contentValues.Put(ColumnTime, reminder.Time);
            contentValues.Put(ColumnNote, reminder.Note);

            db.Insert(TableName, null, contentValues);
            db.Close();
        }
示例#30
0
        public void AddEvent(DateTime startTime, DateTime endTime, string title, string location, string message, Action <bool> callback, string id)
        {
            var calId = GetCalendarId();

            if (calId == -1)
            {
                callback(false);
                return;
            }

            ContentValues eventValues = new ContentValues();

            eventValues.Put(CalendarContract.Events.InterfaceConsts.CalendarId, calId);
            eventValues.Put(CalendarContract.Events.InterfaceConsts.Title, title);
            eventValues.Put(CalendarContract.Events.InterfaceConsts.EventLocation, location);
            eventValues.Put(CalendarContract.Events.InterfaceConsts.AllDay, true);
            eventValues.Put(CalendarContract.Events.InterfaceConsts.Description, location + "\n\n" + message);
            eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtstart, GetDateTimeMS(startTime));
            eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtend, GetDateTimeMS(endTime));

            // GitHub issue #9 : Event start and end times need timezone support.
            // https://github.com/xamarin/monodroid-samples/issues/9
            eventValues.Put(CalendarContract.Events.InterfaceConsts.EventTimezone, "US/Eastern");
            eventValues.Put(CalendarContract.Events.InterfaceConsts.EventEndTimezone, "US/Eastern");

            try
            {
                var uri = AndroidUtils.Context.ContentResolver.Insert(CalendarContract.Events.ContentUri, eventValues);
                Console.WriteLine("Uri for new event: {0}", uri);
                long eventID = 0;

                if (!long.TryParse(uri.LastPathSegment, out eventID))
                {
                    callback(false);
                    return;
                }


                //SaveTheDate.Helpers.Settings.AddEventId(id, eventID);

                var reminderValues = new ContentValues();
                reminderValues.Put(CalendarContract.Reminders.InterfaceConsts.Minutes, 60 * 24);
                reminderValues.Put(CalendarContract.Reminders.InterfaceConsts.EventId, eventID);
                reminderValues.Put(CalendarContract.Reminders.InterfaceConsts.Method, (int)RemindersMethod.Alert);
                uri = AndroidUtils.Context.ContentResolver.Insert(CalendarContract.Reminders.ContentUri, reminderValues);
            }
            catch (Exception Exception)
            {
                callback(false);
                return;
            }
            callback(true);
        }
 /// <summary>
 /// The update parameters.
 /// </summary>
 /// <param name="par">
 /// The par.
 /// </param>
 /// <param name="winLen">
 /// The win len.
 /// </param>
 private void UpdateParams(ContentValues par, int winLen)
 {
     par.Put(Formalism.Sequence.ToString(), convoluted.ToString());
     par.Put(Formalism.Alphabet.ToString(), alphabet.ToString());
     par.Put(Parameter.Window, winLen);
 }
 /// <summary>
 /// The update parameters.
 /// </summary>
 /// <param name="par">
 /// The par.
 /// </param>
 /// <param name="nextThreshold">
 /// The next threshold.
 /// </param>
 private void UpdateParams(ContentValues par, double nextThreshold)
 {
     par.Put(Formalism.Sequence, chain = new ComplexChain(inputs[0].Chain));
     par.Put(Parameter.Balance, balance);
     par.Put(Parameter.Window, windowLen);
     par.Put(Parameter.WindowDecrement, windowDec);
     par.Put(Parameter.CurrentThreshold, nextThreshold);
 }
        /// <summary>
        /// The slot.
        /// </summary>
        public new void Slot()
        {
            var par = new ContentValues();
            par.Put(Formalism.Sequence, chain = new ComplexChain(inputs[0].Chain));
            par.Put(Formalism.Alphabet, alphabet = new FrequencyDictionary(chain));

            while (criterion.State(chain, alphabet))
            {
                UpdateParams(par, threshold.Next(criterion));
                var chainSplitter = new SimpleChainSplitter(extractor);
                chain = chainSplitter.Cut(par);
                alphabet = chainSplitter.FrequencyDictionary;
            }
        }