title: Best practice for updating arguments of a fragment?
body: <p>I know about the "newInstance"-Pattern (<a href="https://stackoverflow.com/questions/9245408/best-practice-for-instantiating-a-new-android-fragment">Best practice for instantiating a new Android Fragment</a>). But how do I update these arguments of a fragment for example if another fragment changes data?</p>
  
  <p>I know about callback-methods between Fragments/Activitys, but these callbacks won't update the arguments?!</p>
  
  <p>For example: on creation of the fragment I pass an URI to the it with the bundle.
  Then another fragment changes this URI via changeUri(Uri uri) method callback on the first fragment.
  If then the fragment gets recreated (for example due to screen rotation) it will use the first URI from the arguments bundle instead of the later updated uri, correct?</p>
  
  <p>What is the best practice to solve this? Do I have to manually store it in the savedInstanceState and on usage decide whether to use the instanceState or arguments-bundle?</p>
  
  <p>I'm looking for a standard way of handling the arguments of my fragments, so I think I'm going with such an approach (pseudo-code):</p>
  
  <pre><code>private Uri arg1;
  
  public static Fragment newInstance(Uri arg1) {
    create bundle
    create fragment instance
    set bundle to fragment
    return fragment
  }
  
  private void onCreate(Bundle savedInstance) {
    if(savedInstance != null) {
      arg1 = savedInstance.uri
    }
  }
  
  private Uri getUri() {
    if(arg1 == null) {
      arg1 = getArguments.uri
    }
    if(arg1 == null) {
      arg1 = defaultValue
    }
  }
  </code></pre>
  
  <p>So I have a simply unified way to access my argument. And don't have to use the if-else-hassle, every time I need that argument.</p>
  
  <p>What do you think about it?</p>