android - Why do filestreams need a context? -


i've been working on developing library company past couple months , have been annoyed fact filestreams seem need context whenever store or load data internal storage.

i have designed library work :

  1. a singleton class made providing , handling keychain(containing app key , device id) , authinfo(user , password)
  2. whenever request call web service made calling class attempt instance of singleton class , keychain , auth info through such :

    singletonclass.getinstance().getcredentials(context ctx);

the result of need provide context of calling activity of library revolves around calling api credentials , device id parameters.

i referring these lines :

....           fileoutputstream fos = ctx.openfileoutput(filename,                                          context.mode_private);           fos.write(buf);           fos.close();  .... 

i confused why specific context of activity calling needed. appreciated. there way of solving design issue ?

the application context should work - consider using method: using application context everywhere? can application context without having pass around.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -