public void updateTable(String mensa, String day) { // set mensa name tv = (TextView) findViewById(R.id.mensa_name); tv.setText(getRealMensaName(mensa)); // set day tv = (TextView) findViewById(R.id.day_date); tv.setText(day + "\r\n" + xmlHandler.getDate(mensa, day)); // set Essen1 title tv = (TextView) findViewById(R.id.essen1); tv.setText("ESSEN 1"); // set Essen1 description tv = (TextView) findViewById(R.id.essen1_desc); tv.setText(xmlHandler.getDataByType(mensa, day, "ESSEN1", "DESC")); // set Essen1 price tv = (TextView) findViewById(R.id.essen1_price); tv.setText(xmlHandler.getDataByType(mensa, day, "ESSEN1", "PRICE")); // set Essen2 title tv = (TextView) findViewById(R.id.essen2); tv.setText("ESSEN 2"); // set Essen2 description tv = (TextView) findViewById(R.id.essen2_desc); tv.setText(xmlHandler.getDataByType(mensa, day, "ESSEN2", "DESC")); // set Essen2 price tv = (TextView) findViewById(R.id.essen2_price); tv.setText(xmlHandler.getDataByType(mensa, day, "ESSEN2", "PRICE")); }
public void writeDatabaseToInternalStorage() { try { FileOutputStream fos = openFileOutput("database.xml", Context.MODE_PRIVATE); fos.write(xmlHandler.toString().getBytes()); fos.close(); } catch (Exception e) { Log.e(TAG, e.getMessage()); } }
public void writeDatabaseToExternalStorage() { if (getExternalStorageState() == EXTERNAL_STORAGE_READABLE_WRITEABLE) { try { File file = new File(this.getExternalFilesDir(null), "database.xml"); OutputStream os = new FileOutputStream(file); os.write(xmlHandler.toString().getBytes()); os.close(); } catch (Exception e) { Log.e(TAG, e.getMessage()); } } }
/** * Save extracted data to the XML database * * @param m Mensa which will be used */ public void saveToDatabase(Mensa m) { for (int i = 0; i < foodDayList.size(); i++) { // Save date if (foodDayList.get(i).getDate() != null) { xmlHandler.addDateToNode(m.getMensaName(), days[i], foodDayList.get(i).getDate()); } else { Log.v(TAG, "Warning in saveToDatabase() : null data"); } // Save ESSEN 1 DESC & PRICE if (foodDayList.get(i).getEssen1Desc() != null && foodDayList.get(i).getEssen1Price() != null) { xmlHandler.addDataToNode( m.getMensaName(), days[i], "ESSEN1", "DESC", foodDayList.get(i).getEssen1Desc(), "PRICE", foodDayList.get(i).getEssen1Price()); } else { Log.v(TAG, "Warning in saveToDatabase() : null data"); } // Save ESSEN 2 DESC & PRICE if (foodDayList.get(i).getEssen2Desc() != null && foodDayList.get(i).getEssen2Price() != null) { xmlHandler.addDataToNode( m.getMensaName(), days[i], "ESSEN2", "DESC", foodDayList.get(i).getEssen2Desc(), "PRICE", foodDayList.get(i).getEssen2Price()); } else { Log.v(TAG, "Warning in saveToDatabase() : null data"); } } // reinitialize foodDayList initFoodDayList(); }