Question: i need to save some crucial importance data when user closes my app. i prefere to do this in `Activity`'s `onPause()`, as it is the latest method guaranteed to be called before the application is destroyed no matter what is the reason of its destruction. however, i save the data in a database, so i use an `AsyncTask`. from my `AsyncTask`, when it's finished, i call a callback method on my `Activity` reference i have saved in the `AsyncTask` before, where i put some variables to `SharedPreferences` indicating that the data has been successfully put to database. 

**my question is:** is the `AsyncTask` guaranteed to finish and the callback to be called on an alive `Activity` reference before it gets destroyed? If not, how to ensure that data is written to database before `Activity` is destroyed?

Answer: 
Use three flows:

```
<flow name="poll-table-1">
  <poll frequency="...">...</poll>
  <flow-ref name="table-data-processor" />
</flow>

<flow name="poll-table-2">
  <poll frequency="...">...</poll>
  <flow-ref name="table-data-processor" />
</flow>

<flow name="table-data-processor">
  ...
</flow>

```
You can try the following way:-

```
<composite-source>
        <poll frequency="10000" doc:name="Poll">
        <processor-chain > 
         <db:select config-ref="Oracle_Configuration" doc:name="Database">
            <db:parameterized-query><![CDATA[select * from Table1]]></db:parameterized-query>
        </db:select> 
         <logger level="INFO" message="Your Payload from Table1:- ....." doc:name="Logger"/>

        <db:select config-ref="Oracle_Configuration" doc:name="Database">
            <db:parameterized-query><![CDATA[select * from Table2]]></db:parameterized-query>
        </db:select>
         <logger level="INFO" message="Your Payload from Table2:- ...." doc:name="Logger"/>
         </processor-chain>
        </poll>
</composite-source>
         <logger level="INFO" message="The remaining flow " doc:name="Logger"/>

```

This is working fine for me :)