//Edit Operation public bool updateTable(Userscore userscore) { try { using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "Scores.db"))) { connection.Query <Userscore>("UPDATE Userscore set Level=?, Name=?, Score=? Where Name=?", userscore.Level, userscore.Name, userscore.Score, userscore.Name); return(true); } } catch (SQLiteException ex) { Log.Info("SQLiteEx", ex.Message); return(false); } }
public void Save_score() { try { Userscore userscore = new Userscore { Name = MainActivity.username, Score = MainActivity.solved_value, Level = MainActivity.levelname }; db.insertIntoTable(userscore); } catch (Exception ex) { Toast.MakeText(this, ex.ToString(), ToastLength.Short).Show(); } }
//Add or Insert Operation public bool insertIntoTable(Userscore userscore) { //Log.Info("AAA","AAA"); try { //Log.Info("BBB", "BBB"); using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "Scores.db"))) { connection.Insert(userscore); return(true); } } catch (SQLiteException ex) { Log.Info("SQLiteEx", ex.Message); return(false); } }
public void Update_topscore() { if (db.getUser(MainActivity.username)) { try { Userscore userscore = new Userscore { Name = MainActivity.username, Score = MainActivity.solved_value, Level = MainActivity.levelname }; db.updateTable(userscore); } catch (Exception ex) { Toast.MakeText(this, ex.ToString(), ToastLength.Short).Show(); } } else { try { Userscore userscore = new Userscore { Name = MainActivity.username, Score = MainActivity.solved_value, Level = MainActivity.levelname }; db.insertIntoTable(userscore); } catch (Exception ex) { Toast.MakeText(this, ex.ToString(), ToastLength.Short).Show(); } } }