Android XML internal storage



I am trying to save some data using XML in android to save into the devices internal storage.


I want to be sure the app is written by the open/closed and single responsibility -principle. (So i could easly switch between methods of storage)



-domain
|---db
|---|---appReader
|---|---|---AppReader.java
|---|---|---XMLAppReader.java
|---|---appWriter
|---|---|---AppWriter.java
|---|---|---XMLAppWriter.java
|---DBFacade.java
|---DBFacadeImpl.java
-MainActivity.java


This is my current structure,...


The problem i am facing now, is that in every tutorial about android and xml they use the function openFileOutput(filename,Context.Mode_Append) I guess this is a function from Activity superclass ?


How would i have to initialise my FileOutputStream and still keep my open/closed and single responsibility principle intact ?


Should i pass an Activity instance to my XMLAppWriter constructor ? Doesn't this undermine the Single responsibility principle ?


No comments:

Post a Comment