title: One "application", multiple packages, database synchronisation
body: <p><strong>Summary</strong>: synchronisation of multiple SQLite databases with server side sequentially.</p>
  
  <p>I'm working on an Android application that is bound to be modular: we have a launcher that fires off intents, based on user choice, to start different application modules (separate installable packages). As it is now, each module has its own SQLite database and that works fine. The task I'm assigned to requires making data synchronisation between handheld and server side (SQL Server 2008 R2) using MS Sync Framework 4.0 (currently October CTP). I had developed android lib according to Sync Framework specs and that works too. </p>
  
  <p>The issue I have is that because of this loosely coupled design (and some other restrictions) I need to have a button in launcher, that forces all modules to synchronise their databases one-by-one (order doesn't matter for now).</p>
  
  <p>My current approach is to have an abstract BroadcastReceiver &amp; Service (I only now discovered IntentService) classes that are inherited in each modules. So in launcher I broadcast intent, each module picks it up using customized BroadcastReceiver and syncs its database using, again, customized Service... In parallel. I have checked ordered broadcasts, but as I have a service doing the actual work it doesn't really help. The only other way I can currently think of is to have a system-wide mutex and use it to lock sync call in every service.</p>
  
  <p>This is my first Android related task so there probably is a better way to solve this, I wouldn't run from redesigning synchronisation part if that makes our teams future life a bit easier.</p>
  
  <p>[<strong>EDIT</strong>] So it looks like Java doesn't support named mutexes.</p>
  
  <p>[<strong>EDIT2</strong>] By modules (or separate installable packages) I meant different APK for each module. So when starting a module you actually start a new process for it.</p>