title: Android DataStore: Calling Context.createDataStore from Java
body: <p>I'm trying to implement the new typed DataStore API in Java and I'm having some issues. All the documentation seems to be in Kotlin only and trying to create a new data store is not as straight forward from the Java side it seems.</p>
  <p>Calling <code>DataStoreFactoryKt.createDataStore()</code> from Java requires me to provide all the arguments including the ones with default values in the Kotlin implementation. There doesnt seem to be any <code>@JvmOverloads</code> annotation for that function, resulting in my predicament.</p>
  <pre><code>fun &lt;T&gt; Context.createDataStore(
      fileName: String,
      serializer: Serializer&lt;T&gt;,
      corruptionHandler: ReplaceFileCorruptionHandler&lt;T&gt;? = null,
      migrations: List&lt;DataMigration&lt;T&gt;&gt; = listOf(),
      scope: CoroutineScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
  ): DataStore&lt;T&gt; =
      DataStoreFactory.create(
          produceFile = { File(this.filesDir, &quot;datastore/$fileName&quot;) },
          serializer = serializer,
          corruptionHandler = corruptionHandler,
          migrations = migrations,
          scope = scope
  )
  </code></pre>
  <p>What's the better way around this, if there is any? Or is the Data Store api simple designed to be used with Kotlin only? I have no idea how I would go about providing a <code>CoroutineScope</code> argument from Java.</p>