title: How can I share a SharedPreferences file across two different android apps?
body: <p>I've been struggling with this for a while. Basically, I want to have two applications (which will always be installed together) share preferences, with one of them being just a service which runs in the background and needs to use the preferences (should own the preferences but only <em>really</em> needs to read them) and the other app being a front-end UI app which needs to be able to write to the preferences file owned by the other app. The service will be doing things in the background (which may be determined by the preferences) and the UI will allow the user to edit the preferences and view some information from the service. However, they will be different packages/apps.</p>
  
  <p>I tried following <a href="http://thedevelopersinfo.com/2009/11/25/getting-sharedpreferences-from-other-application-in-android/">this tutorial</a> which gave me a pretty good idea of how to have preferences in one app which can be read by another. Essentially, I create a new context through <code>myContext = createPackageContext("com.example.package",Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);</code> and then call <code>myContext.getSharedPreferences("pref_name", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);</code> However, I can't write to the preferences successfully from the outside app - (SharedPreferences.Editor).commit() returns false and I get a warning in logcat about being unable to edit pref_name.xml.bak. </p>
  
  <p>How can I successfully set up my applications so both of them can read and write to the same preferences file (which is stored in the data folder of one of them)?</p>