示例#1
0
  /**
   * Insert data into database
   *
   * @param weatherData object which you want to insert
   */
  void addWeather(WeatherData weatherData) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(NAME, weatherData.getCity()); // Name
    values.put(LONG_NAME, weatherData.getCoordLon()); // LON
    values.put(LAT_NAME, weatherData.getCoordLat()); // LON

    // Inserting Row
    db.insert(TABLE_WEATHER, null, values);
    db.close(); // Closing database connection
  }