private void writeToInternalStorage(GeotriggerConfig config) { Log.v(Config.TAG, "writeToInternalStorage"); try { // String endOfLine = System.getProperty("line.separator"); File file = new File(mContext.getFilesDir(), CONFIG_FILE); if (file.exists()) { file.delete(); } file.createNewFile(); // MODE_PRIVATE will create the file (or replace a file of the same name) and make it // private to your application. Other modes available are: MODE_APPEND, MODE_WORLD_READABLE, // and MODE_WORLD_WRITEABLE. FileOutputStream fos = new FileOutputStream(file, false); fos.write(config.toString().getBytes()); Log.v(Config.TAG, "writeFileToInternalStorage complete.. " + config.toString()); // writer.write(userName); fos.close(); } catch (Exception e) { Log.v(Config.TAG, "Error: " + e.getMessage()); } }
TripPlanManager(Context context) { this.mContext = context; GeotriggerConfig config = this.readFromInternalStorage(); if (config != null) { this.tripplan = config.getTripPlan(); this.isEnabled = config.isEnabled(); } }
public void save() { GeotriggerConfig config = new GeotriggerConfig(); config.setEnabled(isEnabled); config.setTripPlan(tripplan); writeToInternalStorage(config); }