Exemplo n.º 1
0
  public void saveDestination(Destination d) {
    SQLiteDatabase db = helper.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(SurvivalappContract.SurvivalEntry.CULUMN_NAME_DESTINATION, d.getDestination());

    db.insert(SurvivalappContract.SurvivalEntry.TABLE_NAME, null, values);

    db.close();
  }
Exemplo n.º 2
0
  public void saveItem(Item t) {
    SQLiteDatabase db = helper.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(SurvivalappItemContract.SurvivalItemEntry.CULUMN_NAME_ITEM, t.getItem());
    values.put(SurvivalappItemContract.SurvivalItemEntry.CULUMN_NAME_SURVIVALID, t.getDestID());

    db.insert(SurvivalappItemContract.SurvivalItemEntry.TABLE_NAME, null, values);

    db.close();
  }
Exemplo n.º 3
0
  public List<Destination> getAllDestinations() {
    List<Destination> destinations = new LinkedList<Destination>();

    String query = "SELECT  * FROM " + SurvivalappContract.SurvivalEntry.TABLE_NAME;

    SQLiteDatabase db = helper.getWritableDatabase();
    Cursor cursor = db.rawQuery(query, null);

    Destination dest = null;
    if (cursor.moveToFirst()) {
      do {
        dest = new Destination();
        dest.setMyID(Integer.parseInt(cursor.getString(0)));
        dest.setDestination(cursor.getString(1));

        destinations.add(dest);
      } while (cursor.moveToNext());
    }

    return destinations;
  }