[go: nahoru, domu]

Split out datastore and datastore-core modules

Test: Ran all datastore tests
Bug: 168512698
Relnote: Created a pure kotlin dependency for datastore to allow for faster compilation
Change-Id: I42d75d0f66dc0cac19bd0f452a84b58806a65a46
diff --git a/buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt b/buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt
index ab84be8..8d13da2 100644
--- a/buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt
@@ -69,6 +69,8 @@
     prebuilts(LibraryGroups.CORE, "core-role", "1.1.0-alpha02")
     prebuilts(LibraryGroups.CURSORADAPTER, "1.0.0")
     prebuilts(LibraryGroups.CUSTOMVIEW, "1.1.0")
+    // Ignore datastore artifact until the 1.0.0-alpha03 prebuilt is imported
+    ignore(LibraryGroups.DATASTORE.group, "datastore")
     ignore(LibraryGroups.DATASTORE.group, "datastore-preferences-proto")
     ignore(LibraryGroups.DATASTORE.group, "datastore-proto")
     prebuilts(LibraryGroups.DATASTORE, "1.0.0-alpha02")
diff --git a/datastore/datastore-core/api/1.0.0-alpha01.txt b/datastore/datastore-core/api/1.0.0-alpha01.txt
new file mode 100644
index 0000000..143e704
--- /dev/null
+++ b/datastore/datastore-core/api/1.0.0-alpha01.txt
@@ -0,0 +1,72 @@
+// Signature format: 3.0
+package androidx.datastore {
+
+  public final class CorruptionException extends java.io.IOException {
+    ctor public CorruptionException(String message, Throwable? cause);
+  }
+
+  public interface CorruptionHandler<T> {
+    method public suspend Object? handleCorruption(androidx.datastore.core.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p);
+  }
+
+  public interface DataMigration<T> {
+    method public suspend Object? cleanUp(kotlin.coroutines.Continuation<? super kotlin.Unit> p);
+    method public suspend Object? migrate(T? currentData, kotlin.coroutines.Continuation<? super T> p);
+    method public suspend Object? shouldMigrate(T? currentData, kotlin.coroutines.Continuation<? super java.lang.Boolean> p);
+  }
+
+  public interface DataStore<T> {
+    method public kotlinx.coroutines.flow.Flow<T> getData();
+    method public suspend Object? updateData(kotlin.jvm.functions.Function2<? super T,? super kotlin.coroutines.Continuation<? super T>,?> transform, kotlin.coroutines.Continuation<? super T> p);
+    property public abstract kotlinx.coroutines.flow.Flow<T> data;
+  }
+
+  public final class DataStoreFactory {
+    ctor public DataStoreFactory();
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler = null, java.util.List<? extends kotlin.jvm.functions.Function0<? extends androidx.datastore.core.DataMigration<T>>> migrationProducers = listOf(), kotlinx.coroutines.CoroutineScope scope = CoroutineScope(Dispatchers.IO + SupervisorJob()));
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler = null, java.util.List<? extends kotlin.jvm.functions.Function0<? extends androidx.datastore.core.DataMigration<T>>> migrationProducers = listOf());
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler = null);
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer);
+  }
+
+  public interface Serializer<T> {
+    method public T! readFrom(java.io.InputStream input);
+    method public void writeTo(T? t, java.io.OutputStream output);
+  }
+
+}
+
+package androidx.datastore.handlers {
+
+  public final class ReplaceFileCorruptionHandler<T> implements androidx.datastore.core.CorruptionHandler<T> {
+    ctor public ReplaceFileCorruptionHandler(kotlin.jvm.functions.Function1<? super androidx.datastore.core.CorruptionException,? extends T> produceNewData);
+    method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public suspend Object? handleCorruption(androidx.datastore.core.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p) throws java.io.IOException;
+  }
+
+}
+
+package androidx.datastore.migrations {
+
+  public interface MigrationFromSharedPreferences<T> {
+    method public suspend Object? migrate(SharedPreferencesView prefs, T? currentData, kotlin.coroutines.Continuation<? super T> p);
+    method public default suspend Object? shouldMigrate(T? currentData, kotlin.coroutines.Continuation<? super java.lang.Boolean> p);
+  }
+
+  public final class SharedPreferencesMigration {
+    method public static <T> kotlin.jvm.functions.Function0<androidx.datastore.core.DataMigration<T>> SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, androidx.datastore.migrations.MigrationFromSharedPreferences<T> migration, java.util.Set<java.lang.String>? keysToMigrate = MIGRATE_ALL_KEYS, boolean deleteEmptyPreferences = true);
+  }
+
+  public final class SharedPreferencesView {
+    ctor public SharedPreferencesView(android.content.SharedPreferences prefs, java.util.Set<java.lang.String> keySet);
+    method public operator boolean contains(String key);
+    method public java.util.Map<java.lang.String,java.lang.Object> getAll();
+    method public boolean getBoolean(String key, boolean defValue);
+    method public float getFloat(String key, float defValue);
+    method public int getInt(String key, int defValue);
+    method public long getLong(String key, long defValue);
+    method public String? getString(String key, String? defValue = null);
+    method public java.util.Set<java.lang.String>? getStringSet(String key, java.util.Set<java.lang.String>? defValues = null);
+  }
+
+}
+
diff --git a/datastore/datastore-core/api/current.txt b/datastore/datastore-core/api/current.txt
index b4f4262..f7d5f1d 100644
--- a/datastore/datastore-core/api/current.txt
+++ b/datastore/datastore-core/api/current.txt
@@ -1,12 +1,12 @@
 // Signature format: 4.0
-package androidx.datastore {
+package androidx.datastore.core {
 
   public final class CorruptionException extends java.io.IOException {
     ctor public CorruptionException(String message, Throwable? cause);
   }
 
   public interface CorruptionHandler<T> {
-    method public suspend Object? handleCorruption(androidx.datastore.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p);
+    method public suspend Object? handleCorruption(androidx.datastore.core.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p);
   }
 
   public interface DataMigration<T> {
@@ -22,15 +22,11 @@
   }
 
   public final class DataStoreFactory {
-    method public <T> androidx.datastore.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.Serializer<T> serializer, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.DataMigration<T>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
-    method public <T> androidx.datastore.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.Serializer<T> serializer, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.DataMigration<T>> migrations);
-    method public <T> androidx.datastore.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.Serializer<T> serializer, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler);
-    method public <T> androidx.datastore.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.Serializer<T> serializer);
-    field public static final androidx.datastore.DataStoreFactory INSTANCE;
-  }
-
-  public final class DataStoreFactoryKt {
-    method public static <T> androidx.datastore.DataStore<T> createDataStore(android.content.Context, String fileName, androidx.datastore.Serializer<T> serializer, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.DataMigration<T>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.core.DataMigration<T>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.core.DataMigration<T>> migrations);
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler);
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer);
+    field public static final androidx.datastore.core.DataStoreFactory INSTANCE;
   }
 
   public interface Serializer<T> {
@@ -40,40 +36,11 @@
 
 }
 
-package androidx.datastore.handlers {
+package androidx.datastore.core.handlers {
 
-  public final class ReplaceFileCorruptionHandler<T> implements androidx.datastore.CorruptionHandler<T> {
-    ctor public ReplaceFileCorruptionHandler(kotlin.jvm.functions.Function1<? super androidx.datastore.CorruptionException,? extends T> produceNewData);
-    method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public suspend Object? handleCorruption(androidx.datastore.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p) throws java.io.IOException;
-  }
-
-}
-
-package androidx.datastore.migrations {
-
-  public final class SharedPreferencesMigration<T> implements androidx.datastore.DataMigration<T> {
-    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, boolean deleteEmptyPreferences, kotlin.jvm.functions.Function2<? super T,? super kotlin.coroutines.Continuation<? super java.lang.Boolean>,?> shouldRunMigration, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
-    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, boolean deleteEmptyPreferences, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
-    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
-    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
-    method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public suspend Object? cleanUp(kotlin.coroutines.Continuation<? super kotlin.Unit> p) throws java.io.IOException;
-    method public suspend Object? migrate(T? currentData, kotlin.coroutines.Continuation<? super T> p);
-    method public suspend Object? shouldMigrate(T? currentData, kotlin.coroutines.Continuation<? super java.lang.Boolean> p);
-  }
-
-  public final class SharedPreferencesMigrationKt {
-  }
-
-  public final class SharedPreferencesView {
-    ctor public SharedPreferencesView(android.content.SharedPreferences prefs, java.util.Set<java.lang.String> keySet);
-    method public operator boolean contains(String key);
-    method public java.util.Map<java.lang.String,java.lang.Object> getAll();
-    method public boolean getBoolean(String key, boolean defValue);
-    method public float getFloat(String key, float defValue);
-    method public int getInt(String key, int defValue);
-    method public long getLong(String key, long defValue);
-    method public String? getString(String key, optional String? defValue);
-    method public java.util.Set<java.lang.String>? getStringSet(String key, optional java.util.Set<java.lang.String>? defValues);
+  public final class ReplaceFileCorruptionHandler<T> implements androidx.datastore.core.CorruptionHandler<T> {
+    ctor public ReplaceFileCorruptionHandler(kotlin.jvm.functions.Function1<? super androidx.datastore.core.CorruptionException,? extends T> produceNewData);
+    method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public suspend Object? handleCorruption(androidx.datastore.core.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p) throws java.io.IOException;
   }
 
 }
diff --git a/datastore/datastore-core/api/public_plus_experimental_1.0.0-alpha01.txt b/datastore/datastore-core/api/public_plus_experimental_1.0.0-alpha01.txt
new file mode 100644
index 0000000..143e704
--- /dev/null
+++ b/datastore/datastore-core/api/public_plus_experimental_1.0.0-alpha01.txt
@@ -0,0 +1,72 @@
+// Signature format: 3.0
+package androidx.datastore {
+
+  public final class CorruptionException extends java.io.IOException {
+    ctor public CorruptionException(String message, Throwable? cause);
+  }
+
+  public interface CorruptionHandler<T> {
+    method public suspend Object? handleCorruption(androidx.datastore.core.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p);
+  }
+
+  public interface DataMigration<T> {
+    method public suspend Object? cleanUp(kotlin.coroutines.Continuation<? super kotlin.Unit> p);
+    method public suspend Object? migrate(T? currentData, kotlin.coroutines.Continuation<? super T> p);
+    method public suspend Object? shouldMigrate(T? currentData, kotlin.coroutines.Continuation<? super java.lang.Boolean> p);
+  }
+
+  public interface DataStore<T> {
+    method public kotlinx.coroutines.flow.Flow<T> getData();
+    method public suspend Object? updateData(kotlin.jvm.functions.Function2<? super T,? super kotlin.coroutines.Continuation<? super T>,?> transform, kotlin.coroutines.Continuation<? super T> p);
+    property public abstract kotlinx.coroutines.flow.Flow<T> data;
+  }
+
+  public final class DataStoreFactory {
+    ctor public DataStoreFactory();
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler = null, java.util.List<? extends kotlin.jvm.functions.Function0<? extends androidx.datastore.core.DataMigration<T>>> migrationProducers = listOf(), kotlinx.coroutines.CoroutineScope scope = CoroutineScope(Dispatchers.IO + SupervisorJob()));
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler = null, java.util.List<? extends kotlin.jvm.functions.Function0<? extends androidx.datastore.core.DataMigration<T>>> migrationProducers = listOf());
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler = null);
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer);
+  }
+
+  public interface Serializer<T> {
+    method public T! readFrom(java.io.InputStream input);
+    method public void writeTo(T? t, java.io.OutputStream output);
+  }
+
+}
+
+package androidx.datastore.handlers {
+
+  public final class ReplaceFileCorruptionHandler<T> implements androidx.datastore.core.CorruptionHandler<T> {
+    ctor public ReplaceFileCorruptionHandler(kotlin.jvm.functions.Function1<? super androidx.datastore.core.CorruptionException,? extends T> produceNewData);
+    method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public suspend Object? handleCorruption(androidx.datastore.core.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p) throws java.io.IOException;
+  }
+
+}
+
+package androidx.datastore.migrations {
+
+  public interface MigrationFromSharedPreferences<T> {
+    method public suspend Object? migrate(SharedPreferencesView prefs, T? currentData, kotlin.coroutines.Continuation<? super T> p);
+    method public default suspend Object? shouldMigrate(T? currentData, kotlin.coroutines.Continuation<? super java.lang.Boolean> p);
+  }
+
+  public final class SharedPreferencesMigration {
+    method public static <T> kotlin.jvm.functions.Function0<androidx.datastore.core.DataMigration<T>> SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, androidx.datastore.migrations.MigrationFromSharedPreferences<T> migration, java.util.Set<java.lang.String>? keysToMigrate = MIGRATE_ALL_KEYS, boolean deleteEmptyPreferences = true);
+  }
+
+  public final class SharedPreferencesView {
+    ctor public SharedPreferencesView(android.content.SharedPreferences prefs, java.util.Set<java.lang.String> keySet);
+    method public operator boolean contains(String key);
+    method public java.util.Map<java.lang.String,java.lang.Object> getAll();
+    method public boolean getBoolean(String key, boolean defValue);
+    method public float getFloat(String key, float defValue);
+    method public int getInt(String key, int defValue);
+    method public long getLong(String key, long defValue);
+    method public String? getString(String key, String? defValue = null);
+    method public java.util.Set<java.lang.String>? getStringSet(String key, java.util.Set<java.lang.String>? defValues = null);
+  }
+
+}
+
diff --git a/datastore/datastore-core/api/public_plus_experimental_current.txt b/datastore/datastore-core/api/public_plus_experimental_current.txt
index b4f4262..f7d5f1d 100644
--- a/datastore/datastore-core/api/public_plus_experimental_current.txt
+++ b/datastore/datastore-core/api/public_plus_experimental_current.txt
@@ -1,12 +1,12 @@
 // Signature format: 4.0
-package androidx.datastore {
+package androidx.datastore.core {
 
   public final class CorruptionException extends java.io.IOException {
     ctor public CorruptionException(String message, Throwable? cause);
   }
 
   public interface CorruptionHandler<T> {
-    method public suspend Object? handleCorruption(androidx.datastore.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p);
+    method public suspend Object? handleCorruption(androidx.datastore.core.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p);
   }
 
   public interface DataMigration<T> {
@@ -22,15 +22,11 @@
   }
 
   public final class DataStoreFactory {
-    method public <T> androidx.datastore.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.Serializer<T> serializer, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.DataMigration<T>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
-    method public <T> androidx.datastore.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.Serializer<T> serializer, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.DataMigration<T>> migrations);
-    method public <T> androidx.datastore.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.Serializer<T> serializer, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler);
-    method public <T> androidx.datastore.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.Serializer<T> serializer);
-    field public static final androidx.datastore.DataStoreFactory INSTANCE;
-  }
-
-  public final class DataStoreFactoryKt {
-    method public static <T> androidx.datastore.DataStore<T> createDataStore(android.content.Context, String fileName, androidx.datastore.Serializer<T> serializer, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.DataMigration<T>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.core.DataMigration<T>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.core.DataMigration<T>> migrations);
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler);
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer);
+    field public static final androidx.datastore.core.DataStoreFactory INSTANCE;
   }
 
   public interface Serializer<T> {
@@ -40,40 +36,11 @@
 
 }
 
-package androidx.datastore.handlers {
+package androidx.datastore.core.handlers {
 
-  public final class ReplaceFileCorruptionHandler<T> implements androidx.datastore.CorruptionHandler<T> {
-    ctor public ReplaceFileCorruptionHandler(kotlin.jvm.functions.Function1<? super androidx.datastore.CorruptionException,? extends T> produceNewData);
-    method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public suspend Object? handleCorruption(androidx.datastore.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p) throws java.io.IOException;
-  }
-
-}
-
-package androidx.datastore.migrations {
-
-  public final class SharedPreferencesMigration<T> implements androidx.datastore.DataMigration<T> {
-    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, boolean deleteEmptyPreferences, kotlin.jvm.functions.Function2<? super T,? super kotlin.coroutines.Continuation<? super java.lang.Boolean>,?> shouldRunMigration, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
-    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, boolean deleteEmptyPreferences, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
-    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
-    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
-    method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public suspend Object? cleanUp(kotlin.coroutines.Continuation<? super kotlin.Unit> p) throws java.io.IOException;
-    method public suspend Object? migrate(T? currentData, kotlin.coroutines.Continuation<? super T> p);
-    method public suspend Object? shouldMigrate(T? currentData, kotlin.coroutines.Continuation<? super java.lang.Boolean> p);
-  }
-
-  public final class SharedPreferencesMigrationKt {
-  }
-
-  public final class SharedPreferencesView {
-    ctor public SharedPreferencesView(android.content.SharedPreferences prefs, java.util.Set<java.lang.String> keySet);
-    method public operator boolean contains(String key);
-    method public java.util.Map<java.lang.String,java.lang.Object> getAll();
-    method public boolean getBoolean(String key, boolean defValue);
-    method public float getFloat(String key, float defValue);
-    method public int getInt(String key, int defValue);
-    method public long getLong(String key, long defValue);
-    method public String? getString(String key, optional String? defValue);
-    method public java.util.Set<java.lang.String>? getStringSet(String key, optional java.util.Set<java.lang.String>? defValues);
+  public final class ReplaceFileCorruptionHandler<T> implements androidx.datastore.core.CorruptionHandler<T> {
+    ctor public ReplaceFileCorruptionHandler(kotlin.jvm.functions.Function1<? super androidx.datastore.core.CorruptionException,? extends T> produceNewData);
+    method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public suspend Object? handleCorruption(androidx.datastore.core.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p) throws java.io.IOException;
   }
 
 }
diff --git a/datastore/datastore-core/api/restricted_1.0.0-alpha01.txt b/datastore/datastore-core/api/restricted_1.0.0-alpha01.txt
new file mode 100644
index 0000000..143e704
--- /dev/null
+++ b/datastore/datastore-core/api/restricted_1.0.0-alpha01.txt
@@ -0,0 +1,72 @@
+// Signature format: 3.0
+package androidx.datastore {
+
+  public final class CorruptionException extends java.io.IOException {
+    ctor public CorruptionException(String message, Throwable? cause);
+  }
+
+  public interface CorruptionHandler<T> {
+    method public suspend Object? handleCorruption(androidx.datastore.core.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p);
+  }
+
+  public interface DataMigration<T> {
+    method public suspend Object? cleanUp(kotlin.coroutines.Continuation<? super kotlin.Unit> p);
+    method public suspend Object? migrate(T? currentData, kotlin.coroutines.Continuation<? super T> p);
+    method public suspend Object? shouldMigrate(T? currentData, kotlin.coroutines.Continuation<? super java.lang.Boolean> p);
+  }
+
+  public interface DataStore<T> {
+    method public kotlinx.coroutines.flow.Flow<T> getData();
+    method public suspend Object? updateData(kotlin.jvm.functions.Function2<? super T,? super kotlin.coroutines.Continuation<? super T>,?> transform, kotlin.coroutines.Continuation<? super T> p);
+    property public abstract kotlinx.coroutines.flow.Flow<T> data;
+  }
+
+  public final class DataStoreFactory {
+    ctor public DataStoreFactory();
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler = null, java.util.List<? extends kotlin.jvm.functions.Function0<? extends androidx.datastore.core.DataMigration<T>>> migrationProducers = listOf(), kotlinx.coroutines.CoroutineScope scope = CoroutineScope(Dispatchers.IO + SupervisorJob()));
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler = null, java.util.List<? extends kotlin.jvm.functions.Function0<? extends androidx.datastore.core.DataMigration<T>>> migrationProducers = listOf());
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler = null);
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer);
+  }
+
+  public interface Serializer<T> {
+    method public T! readFrom(java.io.InputStream input);
+    method public void writeTo(T? t, java.io.OutputStream output);
+  }
+
+}
+
+package androidx.datastore.handlers {
+
+  public final class ReplaceFileCorruptionHandler<T> implements androidx.datastore.core.CorruptionHandler<T> {
+    ctor public ReplaceFileCorruptionHandler(kotlin.jvm.functions.Function1<? super androidx.datastore.core.CorruptionException,? extends T> produceNewData);
+    method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public suspend Object? handleCorruption(androidx.datastore.core.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p) throws java.io.IOException;
+  }
+
+}
+
+package androidx.datastore.migrations {
+
+  public interface MigrationFromSharedPreferences<T> {
+    method public suspend Object? migrate(SharedPreferencesView prefs, T? currentData, kotlin.coroutines.Continuation<? super T> p);
+    method public default suspend Object? shouldMigrate(T? currentData, kotlin.coroutines.Continuation<? super java.lang.Boolean> p);
+  }
+
+  public final class SharedPreferencesMigration {
+    method public static <T> kotlin.jvm.functions.Function0<androidx.datastore.core.DataMigration<T>> SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, androidx.datastore.migrations.MigrationFromSharedPreferences<T> migration, java.util.Set<java.lang.String>? keysToMigrate = MIGRATE_ALL_KEYS, boolean deleteEmptyPreferences = true);
+  }
+
+  public final class SharedPreferencesView {
+    ctor public SharedPreferencesView(android.content.SharedPreferences prefs, java.util.Set<java.lang.String> keySet);
+    method public operator boolean contains(String key);
+    method public java.util.Map<java.lang.String,java.lang.Object> getAll();
+    method public boolean getBoolean(String key, boolean defValue);
+    method public float getFloat(String key, float defValue);
+    method public int getInt(String key, int defValue);
+    method public long getLong(String key, long defValue);
+    method public String? getString(String key, String? defValue = null);
+    method public java.util.Set<java.lang.String>? getStringSet(String key, java.util.Set<java.lang.String>? defValues = null);
+  }
+
+}
+
diff --git a/datastore/datastore-core/api/restricted_current.txt b/datastore/datastore-core/api/restricted_current.txt
index b4f4262..f7d5f1d 100644
--- a/datastore/datastore-core/api/restricted_current.txt
+++ b/datastore/datastore-core/api/restricted_current.txt
@@ -1,12 +1,12 @@
 // Signature format: 4.0
-package androidx.datastore {
+package androidx.datastore.core {
 
   public final class CorruptionException extends java.io.IOException {
     ctor public CorruptionException(String message, Throwable? cause);
   }
 
   public interface CorruptionHandler<T> {
-    method public suspend Object? handleCorruption(androidx.datastore.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p);
+    method public suspend Object? handleCorruption(androidx.datastore.core.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p);
   }
 
   public interface DataMigration<T> {
@@ -22,15 +22,11 @@
   }
 
   public final class DataStoreFactory {
-    method public <T> androidx.datastore.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.Serializer<T> serializer, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.DataMigration<T>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
-    method public <T> androidx.datastore.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.Serializer<T> serializer, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.DataMigration<T>> migrations);
-    method public <T> androidx.datastore.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.Serializer<T> serializer, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler);
-    method public <T> androidx.datastore.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.Serializer<T> serializer);
-    field public static final androidx.datastore.DataStoreFactory INSTANCE;
-  }
-
-  public final class DataStoreFactoryKt {
-    method public static <T> androidx.datastore.DataStore<T> createDataStore(android.content.Context, String fileName, androidx.datastore.Serializer<T> serializer, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.DataMigration<T>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.core.DataMigration<T>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.core.DataMigration<T>> migrations);
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler);
+    method public <T> androidx.datastore.core.DataStore<T> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, androidx.datastore.core.Serializer<T> serializer);
+    field public static final androidx.datastore.core.DataStoreFactory INSTANCE;
   }
 
   public interface Serializer<T> {
@@ -40,40 +36,11 @@
 
 }
 
-package androidx.datastore.handlers {
+package androidx.datastore.core.handlers {
 
-  public final class ReplaceFileCorruptionHandler<T> implements androidx.datastore.CorruptionHandler<T> {
-    ctor public ReplaceFileCorruptionHandler(kotlin.jvm.functions.Function1<? super androidx.datastore.CorruptionException,? extends T> produceNewData);
-    method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public suspend Object? handleCorruption(androidx.datastore.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p) throws java.io.IOException;
-  }
-
-}
-
-package androidx.datastore.migrations {
-
-  public final class SharedPreferencesMigration<T> implements androidx.datastore.DataMigration<T> {
-    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, boolean deleteEmptyPreferences, kotlin.jvm.functions.Function2<? super T,? super kotlin.coroutines.Continuation<? super java.lang.Boolean>,?> shouldRunMigration, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
-    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, boolean deleteEmptyPreferences, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
-    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
-    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
-    method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public suspend Object? cleanUp(kotlin.coroutines.Continuation<? super kotlin.Unit> p) throws java.io.IOException;
-    method public suspend Object? migrate(T? currentData, kotlin.coroutines.Continuation<? super T> p);
-    method public suspend Object? shouldMigrate(T? currentData, kotlin.coroutines.Continuation<? super java.lang.Boolean> p);
-  }
-
-  public final class SharedPreferencesMigrationKt {
-  }
-
-  public final class SharedPreferencesView {
-    ctor public SharedPreferencesView(android.content.SharedPreferences prefs, java.util.Set<java.lang.String> keySet);
-    method public operator boolean contains(String key);
-    method public java.util.Map<java.lang.String,java.lang.Object> getAll();
-    method public boolean getBoolean(String key, boolean defValue);
-    method public float getFloat(String key, float defValue);
-    method public int getInt(String key, int defValue);
-    method public long getLong(String key, long defValue);
-    method public String? getString(String key, optional String? defValue);
-    method public java.util.Set<java.lang.String>? getStringSet(String key, optional java.util.Set<java.lang.String>? defValues);
+  public final class ReplaceFileCorruptionHandler<T> implements androidx.datastore.core.CorruptionHandler<T> {
+    ctor public ReplaceFileCorruptionHandler(kotlin.jvm.functions.Function1<? super androidx.datastore.core.CorruptionException,? extends T> produceNewData);
+    method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public suspend Object? handleCorruption(androidx.datastore.core.CorruptionException ex, kotlin.coroutines.Continuation<? super T> p) throws java.io.IOException;
   }
 
 }
diff --git a/datastore/datastore-core/build.gradle b/datastore/datastore-core/build.gradle
index d6290f4..ef4b53d 100644
--- a/datastore/datastore-core/build.gradle
+++ b/datastore/datastore-core/build.gradle
@@ -16,23 +16,12 @@
 
 import static androidx.build.dependencies.DependenciesKt.*
 import androidx.build.LibraryGroups
-import androidx.build.AndroidXExtension
 import androidx.build.Publish
 import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
 
 plugins {
     id("AndroidXPlugin")
-    id("com.android.library")
-    id("kotlin-android")
-}
-
-android {
-    sourceSets {
-        androidTest {
-            // Shared TestingSerializer between test and androidTest
-            kotlin.srcDirs += test.kotlin.srcDirs
-        }
-    }
+    id("kotlin")
 }
 
 dependencies {
@@ -44,13 +33,6 @@
     testImplementation(KOTLIN_COROUTINES_TEST)
     testImplementation(TRUTH)
     testImplementation(project(":internal-testutils-truth"))
-
-    androidTestImplementation(JUNIT)
-    androidTestImplementation(KOTLIN_COROUTINES_TEST)
-    androidTestImplementation(TRUTH)
-    androidTestImplementation(project(":internal-testutils-truth"))
-    androidTestImplementation(ANDROIDX_TEST_RUNNER)
-    androidTestImplementation(ANDROIDX_TEST_CORE)
 }
 
 androidx {
diff --git a/datastore/datastore-core/lint-baseline.xml b/datastore/datastore-core/lint-baseline.xml
deleted file mode 100644
index 0a5aa55..0000000
--- a/datastore/datastore-core/lint-baseline.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<issues format="5" by="lint 4.2.0-alpha06" client="gradle" variant="debug" version="4.2.0-alpha06">
-
-    <issue
-        id="UnsafeNewApiCall"
-        message="This call is to a method from API 24, the call containing class androidx.datastore.migrations.SharedPreferencesMigration is not annotated with @RequiresApi(x) where x is at least 24. Either annotate the containing class with at least @RequiresApi(24) or move the call to a static method in a wrapper class annotated with at least @RequiresApi(24)."
-        errorLine1="            if (!context.deleteSharedPreferences(name)) {"
-        errorLine2="                         ~~~~~~~~~~~~~~~~~~~~~~~">
-        <location
-            file="src/main/java/androidx/datastore/migrations/SharedPreferencesMigration.kt"
-            line="114"
-            column="26"/>
-    </issue>
-
-</issues>
diff --git a/datastore/datastore-core/src/main/java/androidx/datastore/CorruptionHandler.kt b/datastore/datastore-core/src/main/java/androidx/datastore/core/CorruptionHandler.kt
similarity index 97%
rename from datastore/datastore-core/src/main/java/androidx/datastore/CorruptionHandler.kt
rename to datastore/datastore-core/src/main/java/androidx/datastore/core/CorruptionHandler.kt
index d0adc08..5a04a5d 100644
--- a/datastore/datastore-core/src/main/java/androidx/datastore/CorruptionHandler.kt
+++ b/datastore/datastore-core/src/main/java/androidx/datastore/core/CorruptionHandler.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.datastore
+package androidx.datastore.core
 
 /**
  * CorruptionHandlers allow recovery from corruption that prevents reading data from the file (as
diff --git a/datastore/datastore-core/src/main/java/androidx/datastore/DataMigration.kt b/datastore/datastore-core/src/main/java/androidx/datastore/core/DataMigration.kt
similarity index 98%
rename from datastore/datastore-core/src/main/java/androidx/datastore/DataMigration.kt
rename to datastore/datastore-core/src/main/java/androidx/datastore/core/DataMigration.kt
index 9826b82..c858653 100644
--- a/datastore/datastore-core/src/main/java/androidx/datastore/DataMigration.kt
+++ b/datastore/datastore-core/src/main/java/androidx/datastore/core/DataMigration.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.datastore
+package androidx.datastore.core
 
 /**
  * Interface for migrations to DataStore. Methods on this migration ([shouldMigrate], [migrate]
diff --git a/datastore/datastore-core/src/main/java/androidx/datastore/DataMigrationInitializer.kt b/datastore/datastore-core/src/main/java/androidx/datastore/core/DataMigrationInitializer.kt
similarity index 98%
rename from datastore/datastore-core/src/main/java/androidx/datastore/DataMigrationInitializer.kt
rename to datastore/datastore-core/src/main/java/androidx/datastore/core/DataMigrationInitializer.kt
index 715a229..24d900c 100644
--- a/datastore/datastore-core/src/main/java/androidx/datastore/DataMigrationInitializer.kt
+++ b/datastore/datastore-core/src/main/java/androidx/datastore/core/DataMigrationInitializer.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.datastore
+package androidx.datastore.core
 
 /**
  * Returns an initializer function created from a list of DataMigrations.
diff --git a/datastore/datastore-core/src/main/java/androidx/datastore/DataStore.kt b/datastore/datastore-core/src/main/java/androidx/datastore/core/DataStore.kt
similarity index 98%
rename from datastore/datastore-core/src/main/java/androidx/datastore/DataStore.kt
rename to datastore/datastore-core/src/main/java/androidx/datastore/core/DataStore.kt
index a1a40a4..655f014 100644
--- a/datastore/datastore-core/src/main/java/androidx/datastore/DataStore.kt
+++ b/datastore/datastore-core/src/main/java/androidx/datastore/core/DataStore.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.datastore
+package androidx.datastore.core
 
 import kotlinx.coroutines.flow.Flow
 import java.io.IOException
diff --git a/datastore/datastore-core/src/main/java/androidx/datastore/DataStoreFactory.kt b/datastore/datastore-core/src/main/java/androidx/datastore/core/DataStoreFactory.kt
similarity index 63%
rename from datastore/datastore-core/src/main/java/androidx/datastore/DataStoreFactory.kt
rename to datastore/datastore-core/src/main/java/androidx/datastore/core/DataStoreFactory.kt
index b11b988..78c8ffa 100644
--- a/datastore/datastore-core/src/main/java/androidx/datastore/DataStoreFactory.kt
+++ b/datastore/datastore-core/src/main/java/androidx/datastore/core/DataStoreFactory.kt
@@ -14,11 +14,10 @@
  * limitations under the License.
  */
 
-package androidx.datastore
+package androidx.datastore.core
 
-import android.content.Context
-import androidx.datastore.handlers.NoOpCorruptionHandler
-import androidx.datastore.handlers.ReplaceFileCorruptionHandler
+import androidx.datastore.core.handlers.NoOpCorruptionHandler
+import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
 import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.SupervisorJob
@@ -65,33 +64,3 @@
             scope = scope
         )
 }
-
-/**
- * Create an instance of SingleProcessDataStore. The user is responsible for ensuring that
- * there is never more than one instance of SingleProcessDataStore acting on a file at a time.
- *
- * @param fileName the filename relative to Context.filesDir that DataStore acts on. The File is
- * obtained by calling File(context.filesDir, fileName). No two instances of DataStore should
- * act on the same file at the same time.
- * @param corruptionHandler The corruptionHandler is invoked if DataStore encounters a
- * [CorruptionException] when attempting to read data. CorruptionExceptions are thrown by
- * serializers when data can not be de-serialized.
- * @param migrations are run before any access to data can occur. Each producer and migration
- * may be run more than once whether or not it already succeeded (potentially because another
- * migration failed or a write to disk failed.)
- * @param scope The scope in which IO operations and transform functions will execute.
- */
-public fun <T> Context.createDataStore(
-    fileName: String,
-    serializer: Serializer<T>,
-    corruptionHandler: ReplaceFileCorruptionHandler<T>? = null,
-    migrations: List<DataMigration<T>> = listOf(),
-    scope: CoroutineScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
-): DataStore<T> =
-    DataStoreFactory.create(
-        produceFile = { File(this.filesDir, "datastore/$fileName") },
-        serializer = serializer,
-        corruptionHandler = corruptionHandler,
-        migrations = migrations,
-        scope = scope
-    )
diff --git a/datastore/datastore-core/src/main/java/androidx/datastore/InitializerApi.kt b/datastore/datastore-core/src/main/java/androidx/datastore/core/InitializerApi.kt
similarity index 97%
rename from datastore/datastore-core/src/main/java/androidx/datastore/InitializerApi.kt
rename to datastore/datastore-core/src/main/java/androidx/datastore/core/InitializerApi.kt
index 04fa313..bf36ecd 100644
--- a/datastore/datastore-core/src/main/java/androidx/datastore/InitializerApi.kt
+++ b/datastore/datastore-core/src/main/java/androidx/datastore/core/InitializerApi.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.datastore
+package androidx.datastore.core
 
 /**
  * The initializer API allows changes to be made to store before data is accessed through
diff --git a/datastore/datastore-core/src/main/java/androidx/datastore/Serializer.kt b/datastore/datastore-core/src/main/java/androidx/datastore/core/Serializer.kt
similarity index 97%
rename from datastore/datastore-core/src/main/java/androidx/datastore/Serializer.kt
rename to datastore/datastore-core/src/main/java/androidx/datastore/core/Serializer.kt
index c1f155e..5883e52a 100644
--- a/datastore/datastore-core/src/main/java/androidx/datastore/Serializer.kt
+++ b/datastore/datastore-core/src/main/java/androidx/datastore/core/Serializer.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.datastore
+package androidx.datastore.core
 
 import java.io.IOException
 import java.io.InputStream
diff --git a/datastore/datastore-core/src/main/java/androidx/datastore/SingleProcessDataStore.kt b/datastore/datastore-core/src/main/java/androidx/datastore/core/SingleProcessDataStore.kt
similarity index 98%
rename from datastore/datastore-core/src/main/java/androidx/datastore/SingleProcessDataStore.kt
rename to datastore/datastore-core/src/main/java/androidx/datastore/core/SingleProcessDataStore.kt
index f560b86..7e53b03 100644
--- a/datastore/datastore-core/src/main/java/androidx/datastore/SingleProcessDataStore.kt
+++ b/datastore/datastore-core/src/main/java/androidx/datastore/core/SingleProcessDataStore.kt
@@ -13,9 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package androidx.datastore
+package androidx.datastore.core
 
-import androidx.datastore.handlers.NoOpCorruptionHandler
+import androidx.datastore.core.handlers.NoOpCorruptionHandler
 import kotlinx.coroutines.CompletableDeferred
 import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.Dispatchers
diff --git a/datastore/datastore-core/src/main/java/androidx/datastore/handlers/NoOpCorruptionHandler.kt b/datastore/datastore-core/src/main/java/androidx/datastore/core/handlers/NoOpCorruptionHandler.kt
similarity index 86%
rename from datastore/datastore-core/src/main/java/androidx/datastore/handlers/NoOpCorruptionHandler.kt
rename to datastore/datastore-core/src/main/java/androidx/datastore/core/handlers/NoOpCorruptionHandler.kt
index ef8133c..e5d140e 100644
--- a/datastore/datastore-core/src/main/java/androidx/datastore/handlers/NoOpCorruptionHandler.kt
+++ b/datastore/datastore-core/src/main/java/androidx/datastore/core/handlers/NoOpCorruptionHandler.kt
@@ -13,10 +13,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package androidx.datastore.handlers
+package androidx.datastore.core.handlers
 
-import androidx.datastore.CorruptionException
-import androidx.datastore.CorruptionHandler
+import androidx.datastore.core.CorruptionException
+import androidx.datastore.core.CorruptionHandler
 
 /**
  * Default corruption handler which does nothing but rethrow the exception.
diff --git a/datastore/datastore-core/src/main/java/androidx/datastore/handlers/ReplaceFileCorruptionHandler.kt b/datastore/datastore-core/src/main/java/androidx/datastore/core/handlers/ReplaceFileCorruptionHandler.kt
similarity index 91%
rename from datastore/datastore-core/src/main/java/androidx/datastore/handlers/ReplaceFileCorruptionHandler.kt
rename to datastore/datastore-core/src/main/java/androidx/datastore/core/handlers/ReplaceFileCorruptionHandler.kt
index 4067226..9d5f18f 100644
--- a/datastore/datastore-core/src/main/java/androidx/datastore/handlers/ReplaceFileCorruptionHandler.kt
+++ b/datastore/datastore-core/src/main/java/androidx/datastore/core/handlers/ReplaceFileCorruptionHandler.kt
@@ -14,10 +14,10 @@
  * limitations under the License.
  */
 
-package androidx.datastore.handlers
+package androidx.datastore.core.handlers
 
-import androidx.datastore.CorruptionException
-import androidx.datastore.CorruptionHandler
+import androidx.datastore.core.CorruptionException
+import androidx.datastore.core.CorruptionHandler
 import java.io.IOException
 import kotlin.jvm.Throws
 
diff --git a/datastore/datastore-core/src/test/java/androidx/datastore/DataMigrationInitializerTest.kt b/datastore/datastore-core/src/test/java/androidx/datastore/core/DataMigrationInitializerTest.kt
similarity index 99%
rename from datastore/datastore-core/src/test/java/androidx/datastore/DataMigrationInitializerTest.kt
rename to datastore/datastore-core/src/test/java/androidx/datastore/core/DataMigrationInitializerTest.kt
index f7c2827..31e28dd 100644
--- a/datastore/datastore-core/src/test/java/androidx/datastore/DataMigrationInitializerTest.kt
+++ b/datastore/datastore-core/src/test/java/androidx/datastore/core/DataMigrationInitializerTest.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.datastore
+package androidx.datastore.core
 
 import androidx.testutils.assertThrows
 import com.google.common.truth.Truth.assertThat
diff --git a/datastore/datastore-core/src/androidTest/java/androidx/datastore/DataStoreFactoryTest.kt b/datastore/datastore-core/src/test/java/androidx/datastore/core/DataStoreFactoryTest.kt
similarity index 72%
rename from datastore/datastore-core/src/androidTest/java/androidx/datastore/DataStoreFactoryTest.kt
rename to datastore/datastore-core/src/test/java/androidx/datastore/core/DataStoreFactoryTest.kt
index 735b9d3..746f31a 100644
--- a/datastore/datastore-core/src/androidTest/java/androidx/datastore/DataStoreFactoryTest.kt
+++ b/datastore/datastore-core/src/test/java/androidx/datastore/core/DataStoreFactoryTest.kt
@@ -14,11 +14,9 @@
  * limitations under the License.
  */
 
-package androidx.datastore
+package androidx.datastore.core
 
-import android.content.Context
-import androidx.datastore.handlers.ReplaceFileCorruptionHandler
-import androidx.test.core.app.ApplicationProvider
+import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
 import com.google.common.truth.Truth.assertThat
 import kotlinx.coroutines.flow.first
 import kotlinx.coroutines.test.TestCoroutineScope
@@ -39,13 +37,11 @@
 
     private lateinit var testFile: File
     private lateinit var dataStoreScope: TestCoroutineScope
-    private lateinit var context: Context
 
     @Before
     fun setUp() {
         testFile = tmp.newFile()
         dataStoreScope = TestCoroutineScope()
-        context = ApplicationProvider.getApplicationContext()
     }
 
     @Test
@@ -108,34 +104,4 @@
 
         assertThat(store.data.first()).isEqualTo(migratedByte)
     }
-
-    @Test
-    fun testCreateWithContextAndName() = runBlockingTest {
-        val byte = 1
-
-        var store = context.createDataStore(
-            serializer = TestingSerializer(),
-            fileName = "my_settings.byte",
-            scope = dataStoreScope
-        )
-        store.updateData { 1 }
-
-        // Create it again and confirm it's still there
-        store = context.createDataStore(
-            serializer = TestingSerializer(),
-            fileName = "my_settings.byte",
-            scope = dataStoreScope
-        )
-        assertThat(store.data.first()).isEqualTo(byte)
-
-        // Check that the file name is context.filesDir + fileName
-        store = DataStoreFactory.create(
-            produceFile = {
-                File(context.filesDir, "datastore/my_settings.byte")
-            },
-            serializer = TestingSerializer(),
-            scope = dataStoreScope
-        )
-        assertThat(store.data.first()).isEqualTo(byte)
-    }
 }
\ No newline at end of file
diff --git a/datastore/datastore-core/src/test/java/androidx/datastore/SingleProcessDataStoreTest.kt b/datastore/datastore-core/src/test/java/androidx/datastore/core/SingleProcessDataStoreTest.kt
similarity index 98%
rename from datastore/datastore-core/src/test/java/androidx/datastore/SingleProcessDataStoreTest.kt
rename to datastore/datastore-core/src/test/java/androidx/datastore/core/SingleProcessDataStoreTest.kt
index 627752e..b0da154 100644
--- a/datastore/datastore-core/src/test/java/androidx/datastore/SingleProcessDataStoreTest.kt
+++ b/datastore/datastore-core/src/test/java/androidx/datastore/core/SingleProcessDataStoreTest.kt
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-package androidx.datastore
+package androidx.datastore.core
 
-import androidx.datastore.handlers.NoOpCorruptionHandler
+import androidx.datastore.core.handlers.NoOpCorruptionHandler
 import androidx.testutils.assertThrows
 import com.google.common.truth.Truth.assertThat
 import kotlinx.coroutines.CancellationException
@@ -67,7 +67,11 @@
         testFile = tempFolder.newFile()
         dataStoreScope = TestCoroutineScope(TestCoroutineDispatcher() + Job())
         store =
-            SingleProcessDataStore<Byte>({ testFile }, serializer, scope = dataStoreScope)
+            SingleProcessDataStore<Byte>(
+                { testFile },
+                serializer,
+                scope = dataStoreScope
+            )
     }
 
     @After
diff --git a/datastore/datastore-core/src/test/java/androidx/datastore/TestingSerializer.kt b/datastore/datastore-core/src/test/java/androidx/datastore/core/TestingSerializer.kt
similarity index 97%
rename from datastore/datastore-core/src/test/java/androidx/datastore/TestingSerializer.kt
rename to datastore/datastore-core/src/test/java/androidx/datastore/core/TestingSerializer.kt
index 769529d..d001f1d 100644
--- a/datastore/datastore-core/src/test/java/androidx/datastore/TestingSerializer.kt
+++ b/datastore/datastore-core/src/test/java/androidx/datastore/core/TestingSerializer.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.datastore
+package androidx.datastore.core
 
 import java.io.IOException
 import java.io.InputStream
diff --git a/datastore/datastore-core/src/test/java/androidx/datastore/handlers/ReplaceFileCorruptionHandlerTest.kt b/datastore/datastore-core/src/test/java/androidx/datastore/core/handlers/ReplaceFileCorruptionHandlerTest.kt
similarity index 96%
rename from datastore/datastore-core/src/test/java/androidx/datastore/handlers/ReplaceFileCorruptionHandlerTest.kt
rename to datastore/datastore-core/src/test/java/androidx/datastore/core/handlers/ReplaceFileCorruptionHandlerTest.kt
index 36c9f14..14a9555 100644
--- a/datastore/datastore-core/src/test/java/androidx/datastore/handlers/ReplaceFileCorruptionHandlerTest.kt
+++ b/datastore/datastore-core/src/test/java/androidx/datastore/core/handlers/ReplaceFileCorruptionHandlerTest.kt
@@ -14,10 +14,10 @@
  * limitations under the License.
  */
 
-package androidx.datastore.handlers
+package androidx.datastore.core.handlers
 
-import androidx.datastore.SingleProcessDataStore
-import androidx.datastore.TestingSerializer
+import androidx.datastore.core.SingleProcessDataStore
+import androidx.datastore.core.TestingSerializer
 import androidx.testutils.assertThrows
 import com.google.common.truth.Truth.assertThat
 import kotlinx.coroutines.async
diff --git a/datastore/datastore-preferences/api/api_lint.ignore b/datastore/datastore-preferences/api/api_lint.ignore
index e064eef..3e56e10 100644
--- a/datastore/datastore-preferences/api/api_lint.ignore
+++ b/datastore/datastore-preferences/api/api_lint.ignore
@@ -1,5 +1,5 @@
 // Baseline format: 1.0
-MissingJvmstatic: androidx.datastore.preferences.PreferenceDataStoreFactory#create(kotlin.jvm.functions.Function0<? extends java.io.File>, androidx.datastore.handlers.ReplaceFileCorruptionHandler<androidx.datastore.preferences.Preferences>, java.util.List<? extends androidx.datastore.DataMigration<androidx.datastore.preferences.Preferences>>, kotlinx.coroutines.CoroutineScope):
+MissingJvmstatic: androidx.datastore.preferences.PreferenceDataStoreFactory#create(kotlin.jvm.functions.Function0<? extends java.io.File>, androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<androidx.datastore.preferences.Preferences>, java.util.List<? extends androidx.datastore.core.DataMigration<androidx.datastore.preferences.Preferences>>, kotlinx.coroutines.CoroutineScope):
     A Kotlin method with default parameter values should be annotated with @JvmOverloads for better Java interoperability; see https://android.github.io/kotlin-guides/interop.html#function-overloads-for-defaults
 
 
diff --git a/datastore/datastore-preferences/api/current.txt b/datastore/datastore-preferences/api/current.txt
index 370a87c..922dae4 100644
--- a/datastore/datastore-preferences/api/current.txt
+++ b/datastore/datastore-preferences/api/current.txt
@@ -9,12 +9,12 @@
   }
 
   public final class PreferenceDataStoreFactory {
-    method public androidx.datastore.DataStore<androidx.datastore.preferences.Preferences> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<androidx.datastore.preferences.Preferences>? corruptionHandler, optional java.util.List<? extends androidx.datastore.DataMigration<androidx.datastore.preferences.Preferences>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
+    method public androidx.datastore.core.DataStore<androidx.datastore.preferences.Preferences> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<androidx.datastore.preferences.Preferences>? corruptionHandler, optional java.util.List<? extends androidx.datastore.core.DataMigration<androidx.datastore.preferences.Preferences>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
     field public static final androidx.datastore.preferences.PreferenceDataStoreFactory INSTANCE;
   }
 
   public final class PreferenceDataStoreFactoryKt {
-    method public static androidx.datastore.DataStore<androidx.datastore.preferences.Preferences> createDataStore(android.content.Context, String name, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<androidx.datastore.preferences.Preferences>? corruptionHandler, optional java.util.List<? extends androidx.datastore.DataMigration<androidx.datastore.preferences.Preferences>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
+    method public static androidx.datastore.core.DataStore<androidx.datastore.preferences.Preferences> createDataStore(android.content.Context, String name, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<androidx.datastore.preferences.Preferences>? corruptionHandler, optional java.util.List<? extends androidx.datastore.core.DataMigration<androidx.datastore.preferences.Preferences>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
   }
 
   public abstract class Preferences {
@@ -33,7 +33,7 @@
 
   public final class PreferencesKt {
     method public static void clear(androidx.datastore.preferences.MutablePreferences);
-    method public static suspend Object? edit(androidx.datastore.DataStore<androidx.datastore.preferences.Preferences>, kotlin.jvm.functions.Function2<? super androidx.datastore.preferences.MutablePreferences,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> transform, kotlin.coroutines.Continuation<? super androidx.datastore.preferences.Preferences> p);
+    method public static suspend Object? edit(androidx.datastore.core.DataStore<androidx.datastore.preferences.Preferences>, kotlin.jvm.functions.Function2<? super androidx.datastore.preferences.MutablePreferences,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> transform, kotlin.coroutines.Continuation<? super androidx.datastore.preferences.Preferences> p);
     method public static androidx.datastore.preferences.Preferences emptyPreferences();
     method public static operator void minusAssign(androidx.datastore.preferences.MutablePreferences, androidx.datastore.preferences.Preferences.Key<?> key);
     method public static androidx.datastore.preferences.MutablePreferences mutablePreferencesOf(androidx.datastore.preferences.Preferences.Pair<?>... pairs);
diff --git a/datastore/datastore-preferences/api/public_plus_experimental_current.txt b/datastore/datastore-preferences/api/public_plus_experimental_current.txt
index 370a87c..922dae4 100644
--- a/datastore/datastore-preferences/api/public_plus_experimental_current.txt
+++ b/datastore/datastore-preferences/api/public_plus_experimental_current.txt
@@ -9,12 +9,12 @@
   }
 
   public final class PreferenceDataStoreFactory {
-    method public androidx.datastore.DataStore<androidx.datastore.preferences.Preferences> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<androidx.datastore.preferences.Preferences>? corruptionHandler, optional java.util.List<? extends androidx.datastore.DataMigration<androidx.datastore.preferences.Preferences>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
+    method public androidx.datastore.core.DataStore<androidx.datastore.preferences.Preferences> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<androidx.datastore.preferences.Preferences>? corruptionHandler, optional java.util.List<? extends androidx.datastore.core.DataMigration<androidx.datastore.preferences.Preferences>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
     field public static final androidx.datastore.preferences.PreferenceDataStoreFactory INSTANCE;
   }
 
   public final class PreferenceDataStoreFactoryKt {
-    method public static androidx.datastore.DataStore<androidx.datastore.preferences.Preferences> createDataStore(android.content.Context, String name, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<androidx.datastore.preferences.Preferences>? corruptionHandler, optional java.util.List<? extends androidx.datastore.DataMigration<androidx.datastore.preferences.Preferences>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
+    method public static androidx.datastore.core.DataStore<androidx.datastore.preferences.Preferences> createDataStore(android.content.Context, String name, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<androidx.datastore.preferences.Preferences>? corruptionHandler, optional java.util.List<? extends androidx.datastore.core.DataMigration<androidx.datastore.preferences.Preferences>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
   }
 
   public abstract class Preferences {
@@ -33,7 +33,7 @@
 
   public final class PreferencesKt {
     method public static void clear(androidx.datastore.preferences.MutablePreferences);
-    method public static suspend Object? edit(androidx.datastore.DataStore<androidx.datastore.preferences.Preferences>, kotlin.jvm.functions.Function2<? super androidx.datastore.preferences.MutablePreferences,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> transform, kotlin.coroutines.Continuation<? super androidx.datastore.preferences.Preferences> p);
+    method public static suspend Object? edit(androidx.datastore.core.DataStore<androidx.datastore.preferences.Preferences>, kotlin.jvm.functions.Function2<? super androidx.datastore.preferences.MutablePreferences,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> transform, kotlin.coroutines.Continuation<? super androidx.datastore.preferences.Preferences> p);
     method public static androidx.datastore.preferences.Preferences emptyPreferences();
     method public static operator void minusAssign(androidx.datastore.preferences.MutablePreferences, androidx.datastore.preferences.Preferences.Key<?> key);
     method public static androidx.datastore.preferences.MutablePreferences mutablePreferencesOf(androidx.datastore.preferences.Preferences.Pair<?>... pairs);
diff --git a/datastore/datastore-preferences/api/restricted_current.txt b/datastore/datastore-preferences/api/restricted_current.txt
index 92289db..9f1fb34 100644
--- a/datastore/datastore-preferences/api/restricted_current.txt
+++ b/datastore/datastore-preferences/api/restricted_current.txt
@@ -9,12 +9,12 @@
   }
 
   public final class PreferenceDataStoreFactory {
-    method public androidx.datastore.DataStore<androidx.datastore.preferences.Preferences> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<androidx.datastore.preferences.Preferences>? corruptionHandler, optional java.util.List<? extends androidx.datastore.DataMigration<androidx.datastore.preferences.Preferences>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
+    method public androidx.datastore.core.DataStore<androidx.datastore.preferences.Preferences> create(kotlin.jvm.functions.Function0<? extends java.io.File> produceFile, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<androidx.datastore.preferences.Preferences>? corruptionHandler, optional java.util.List<? extends androidx.datastore.core.DataMigration<androidx.datastore.preferences.Preferences>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
     field public static final androidx.datastore.preferences.PreferenceDataStoreFactory INSTANCE;
   }
 
   public final class PreferenceDataStoreFactoryKt {
-    method public static androidx.datastore.DataStore<androidx.datastore.preferences.Preferences> createDataStore(android.content.Context, String name, optional androidx.datastore.handlers.ReplaceFileCorruptionHandler<androidx.datastore.preferences.Preferences>? corruptionHandler, optional java.util.List<? extends androidx.datastore.DataMigration<androidx.datastore.preferences.Preferences>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
+    method public static androidx.datastore.core.DataStore<androidx.datastore.preferences.Preferences> createDataStore(android.content.Context, String name, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<androidx.datastore.preferences.Preferences>? corruptionHandler, optional java.util.List<? extends androidx.datastore.core.DataMigration<androidx.datastore.preferences.Preferences>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
   }
 
   public abstract class Preferences {
@@ -34,7 +34,7 @@
 
   public final class PreferencesKt {
     method public static void clear(androidx.datastore.preferences.MutablePreferences);
-    method public static suspend Object? edit(androidx.datastore.DataStore<androidx.datastore.preferences.Preferences>, kotlin.jvm.functions.Function2<? super androidx.datastore.preferences.MutablePreferences,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> transform, kotlin.coroutines.Continuation<? super androidx.datastore.preferences.Preferences> p);
+    method public static suspend Object? edit(androidx.datastore.core.DataStore<androidx.datastore.preferences.Preferences>, kotlin.jvm.functions.Function2<? super androidx.datastore.preferences.MutablePreferences,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> transform, kotlin.coroutines.Continuation<? super androidx.datastore.preferences.Preferences> p);
     method public static androidx.datastore.preferences.Preferences emptyPreferences();
     method public static operator void minusAssign(androidx.datastore.preferences.MutablePreferences, androidx.datastore.preferences.Preferences.Key<?> key);
     method public static androidx.datastore.preferences.MutablePreferences mutablePreferencesOf(androidx.datastore.preferences.Preferences.Pair<?>... pairs);
diff --git a/datastore/datastore-preferences/build.gradle b/datastore/datastore-preferences/build.gradle
index ec22411..d86769f 100644
--- a/datastore/datastore-preferences/build.gradle
+++ b/datastore/datastore-preferences/build.gradle
@@ -52,7 +52,7 @@
 
 dependencies {
     api(KOTLIN_STDLIB)
-    api(project(":datastore:datastore-core"))
+    api(project(":datastore:datastore"))
 
     testImplementation(JUNIT)
     testImplementation(KOTLIN_COROUTINES_TEST)
diff --git a/datastore/datastore-preferences/datastore-preferences-proto/src/main/java/androidx/datastore/preferences/PreferencesMapCompat.kt b/datastore/datastore-preferences/datastore-preferences-proto/src/main/java/androidx/datastore/preferences/PreferencesMapCompat.kt
index b7a00c6..469877b 100644
--- a/datastore/datastore-preferences/datastore-preferences-proto/src/main/java/androidx/datastore/preferences/PreferencesMapCompat.kt
+++ b/datastore/datastore-preferences/datastore-preferences-proto/src/main/java/androidx/datastore/preferences/PreferencesMapCompat.kt
@@ -16,7 +16,7 @@
 
 package androidx.datastore.preferences
 
-import androidx.datastore.CorruptionException
+import androidx.datastore.core.CorruptionException
 import com.google.protobuf.InvalidProtocolBufferException
 import java.io.InputStream
 
diff --git a/datastore/datastore-preferences/src/androidTest/java/androidx/datastore/preferences/PreferenceDataStoreFactoryTest.kt b/datastore/datastore-preferences/src/androidTest/java/androidx/datastore/preferences/PreferenceDataStoreFactoryTest.kt
index 3b6c201..cac2b64 100644
--- a/datastore/datastore-preferences/src/androidTest/java/androidx/datastore/preferences/PreferenceDataStoreFactoryTest.kt
+++ b/datastore/datastore-preferences/src/androidTest/java/androidx/datastore/preferences/PreferenceDataStoreFactoryTest.kt
@@ -17,8 +17,8 @@
 package androidx.datastore.preferences
 
 import android.content.Context
-import androidx.datastore.DataMigration
-import androidx.datastore.handlers.ReplaceFileCorruptionHandler
+import androidx.datastore.core.DataMigration
+import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
 import androidx.test.core.app.ApplicationProvider
 import kotlinx.coroutines.FlowPreview
 import kotlinx.coroutines.ObsoleteCoroutinesApi
diff --git a/datastore/datastore-preferences/src/androidTest/java/androidx/datastore/preferences/SharedPreferencesToPreferencesTest.kt b/datastore/datastore-preferences/src/androidTest/java/androidx/datastore/preferences/SharedPreferencesToPreferencesTest.kt
index 567ebc5..69aab07 100644
--- a/datastore/datastore-preferences/src/androidTest/java/androidx/datastore/preferences/SharedPreferencesToPreferencesTest.kt
+++ b/datastore/datastore-preferences/src/androidTest/java/androidx/datastore/preferences/SharedPreferencesToPreferencesTest.kt
@@ -18,8 +18,8 @@
 
 import android.content.Context
 import android.content.SharedPreferences
-import androidx.datastore.DataMigration
-import androidx.datastore.DataStore
+import androidx.datastore.core.DataMigration
+import androidx.datastore.core.DataStore
 import androidx.test.core.app.ApplicationProvider
 import androidx.test.filters.MediumTest
 import kotlinx.coroutines.flow.first
diff --git a/datastore/datastore-preferences/src/main/java/androidx/datastore/preferences/PreferenceDataStoreFactory.kt b/datastore/datastore-preferences/src/main/java/androidx/datastore/preferences/PreferenceDataStoreFactory.kt
index ded0da4..2c79770 100644
--- a/datastore/datastore-preferences/src/main/java/androidx/datastore/preferences/PreferenceDataStoreFactory.kt
+++ b/datastore/datastore-preferences/src/main/java/androidx/datastore/preferences/PreferenceDataStoreFactory.kt
@@ -17,11 +17,11 @@
 package androidx.datastore.preferences
 
 import android.content.Context
-import androidx.datastore.CorruptionException
-import androidx.datastore.DataMigration
-import androidx.datastore.DataStore
-import androidx.datastore.DataStoreFactory
-import androidx.datastore.handlers.ReplaceFileCorruptionHandler
+import androidx.datastore.core.CorruptionException
+import androidx.datastore.core.DataMigration
+import androidx.datastore.core.DataStore
+import androidx.datastore.core.DataStoreFactory
+import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
 import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.SupervisorJob
diff --git a/datastore/datastore-preferences/src/main/java/androidx/datastore/preferences/Preferences.kt b/datastore/datastore-preferences/src/main/java/androidx/datastore/preferences/Preferences.kt
index ad38653..bfebbec 100644
--- a/datastore/datastore-preferences/src/main/java/androidx/datastore/preferences/Preferences.kt
+++ b/datastore/datastore-preferences/src/main/java/androidx/datastore/preferences/Preferences.kt
@@ -15,7 +15,7 @@
  */
 package androidx.datastore.preferences
 
-import androidx.datastore.DataStore
+import androidx.datastore.core.DataStore
 import java.lang.IllegalArgumentException
 import java.util.Collections
 import java.util.concurrent.atomic.AtomicBoolean
diff --git a/datastore/datastore-preferences/src/main/java/androidx/datastore/preferences/PreferencesSerializer.kt b/datastore/datastore-preferences/src/main/java/androidx/datastore/preferences/PreferencesSerializer.kt
index f9fa69a..f7b3bd4 100644
--- a/datastore/datastore-preferences/src/main/java/androidx/datastore/preferences/PreferencesSerializer.kt
+++ b/datastore/datastore-preferences/src/main/java/androidx/datastore/preferences/PreferencesSerializer.kt
@@ -16,11 +16,11 @@
 
 package androidx.datastore.preferences
 
-import androidx.datastore.CorruptionException
+import androidx.datastore.core.CorruptionException
 import androidx.datastore.preferences.PreferencesProto.PreferenceMap
 import androidx.datastore.preferences.PreferencesProto.Value
 import androidx.datastore.preferences.PreferencesProto.StringSet
-import androidx.datastore.Serializer
+import androidx.datastore.core.Serializer
 import java.io.IOException
 import java.io.InputStream
 import java.io.OutputStream
diff --git a/datastore/datastore-preferences/src/test/java/androidx/datastore/preferences/PreferencesSerializerTest.kt b/datastore/datastore-preferences/src/test/java/androidx/datastore/preferences/PreferencesSerializerTest.kt
index 89663b5..b9ab270 100644
--- a/datastore/datastore-preferences/src/test/java/androidx/datastore/preferences/PreferencesSerializerTest.kt
+++ b/datastore/datastore-preferences/src/test/java/androidx/datastore/preferences/PreferencesSerializerTest.kt
@@ -16,7 +16,7 @@
 
 package androidx.datastore.preferences
 
-import androidx.datastore.CorruptionException
+import androidx.datastore.core.CorruptionException
 import org.junit.Before
 import org.junit.Rule
 import org.junit.Test
diff --git a/datastore/datastore-proto/src/main/java/androidx/datastore/protos/ProtoSerializer.kt b/datastore/datastore-proto/src/main/java/androidx/datastore/protos/ProtoSerializer.kt
index a901c2a..abb2cfd66 100644
--- a/datastore/datastore-proto/src/main/java/androidx/datastore/protos/ProtoSerializer.kt
+++ b/datastore/datastore-proto/src/main/java/androidx/datastore/protos/ProtoSerializer.kt
@@ -16,8 +16,8 @@
 
 package androidx.datastore.protos
 
-import androidx.datastore.CorruptionException
-import androidx.datastore.Serializer
+import androidx.datastore.core.CorruptionException
+import androidx.datastore.core.Serializer
 import com.google.protobuf.ExtensionRegistryLite
 import com.google.protobuf.InvalidProtocolBufferException
 import com.google.protobuf.MessageLite
diff --git a/datastore/datastore-proto/src/test/java/androidx/datastore/protos/ProtoSerializerTest.kt b/datastore/datastore-proto/src/test/java/androidx/datastore/protos/ProtoSerializerTest.kt
index 514374e..aec23de6 100644
--- a/datastore/datastore-proto/src/test/java/androidx/datastore/protos/ProtoSerializerTest.kt
+++ b/datastore/datastore-proto/src/test/java/androidx/datastore/protos/ProtoSerializerTest.kt
@@ -16,7 +16,7 @@
 
 package androidx.datastore.protos
 
-import androidx.datastore.CorruptionException
+import androidx.datastore.core.CorruptionException
 import org.junit.Test
 import androidx.testing.TestMessageProto.FooProto
 import androidx.testing.TestMessageProto.ExtendableProto
diff --git a/datastore/datastore-sampleapp/build.gradle b/datastore/datastore-sampleapp/build.gradle
index 8d60d35..e14b341 100644
--- a/datastore/datastore-sampleapp/build.gradle
+++ b/datastore/datastore-sampleapp/build.gradle
@@ -32,7 +32,7 @@
     implementation(project(":datastore:datastore-preferences"))
 
     // For DataStore with protos
-    implementation(project(":datastore:datastore-core"))
+    implementation(project(":datastore:datastore"))
 
     // For settings fragment
     api("androidx.preference:preference:1.1.1")
diff --git a/datastore/datastore-sampleapp/src/main/java/com/example/datastoresampleapp/PreferencesDataStoreActivity.kt b/datastore/datastore-sampleapp/src/main/java/com/example/datastoresampleapp/PreferencesDataStoreActivity.kt
index a64e83e..10d5c57 100644
--- a/datastore/datastore-sampleapp/src/main/java/com/example/datastoresampleapp/PreferencesDataStoreActivity.kt
+++ b/datastore/datastore-sampleapp/src/main/java/com/example/datastoresampleapp/PreferencesDataStoreActivity.kt
@@ -23,8 +23,7 @@
 import android.widget.TextView
 import androidx.annotation.Sampled
 import androidx.appcompat.app.AppCompatActivity
-import androidx.datastore.DataStore
-import androidx.datastore.createDataStore
+import androidx.datastore.core.DataStore
 import androidx.datastore.preferences.Preferences
 import androidx.datastore.preferences.createDataStore
 import androidx.datastore.preferences.edit
diff --git a/datastore/datastore-sampleapp/src/main/java/com/example/datastoresampleapp/ProtoDataStoreActivity.kt b/datastore/datastore-sampleapp/src/main/java/com/example/datastoresampleapp/ProtoDataStoreActivity.kt
index 8b46d26..a592393 100644
--- a/datastore/datastore-sampleapp/src/main/java/com/example/datastoresampleapp/ProtoDataStoreActivity.kt
+++ b/datastore/datastore-sampleapp/src/main/java/com/example/datastoresampleapp/ProtoDataStoreActivity.kt
@@ -23,10 +23,10 @@
 import android.widget.TextView
 import androidx.annotation.Sampled
 import androidx.appcompat.app.AppCompatActivity
-import androidx.datastore.CorruptionException
-import androidx.datastore.DataStore
-import androidx.datastore.DataStoreFactory
-import androidx.datastore.Serializer
+import androidx.datastore.core.CorruptionException
+import androidx.datastore.core.DataStore
+import androidx.datastore.core.DataStoreFactory
+import androidx.datastore.core.Serializer
 import androidx.lifecycle.lifecycleScope
 import com.google.protobuf.InvalidProtocolBufferException
 import kotlinx.coroutines.flow.catch
diff --git a/datastore/datastore-sampleapp/src/main/java/com/example/datastoresampleapp/SettingsFragment.kt b/datastore/datastore-sampleapp/src/main/java/com/example/datastoresampleapp/SettingsFragment.kt
index b2e8d2b..78f1794 100644
--- a/datastore/datastore-sampleapp/src/main/java/com/example/datastoresampleapp/SettingsFragment.kt
+++ b/datastore/datastore-sampleapp/src/main/java/com/example/datastoresampleapp/SettingsFragment.kt
@@ -22,10 +22,10 @@
 import android.util.Log
 import android.view.View
 import androidx.appcompat.app.AppCompatActivity
-import androidx.datastore.CorruptionException
-import androidx.datastore.DataStore
-import androidx.datastore.DataStoreFactory
-import androidx.datastore.Serializer
+import androidx.datastore.core.CorruptionException
+import androidx.datastore.core.DataStore
+import androidx.datastore.core.DataStoreFactory
+import androidx.datastore.core.Serializer
 import androidx.preference.Preference
 import androidx.preference.SwitchPreference
 import androidx.preference.PreferenceFragmentCompat
diff --git a/datastore/datastore-core/api/api_lint.ignore b/datastore/datastore/api/api_lint.ignore
similarity index 100%
rename from datastore/datastore-core/api/api_lint.ignore
rename to datastore/datastore/api/api_lint.ignore
diff --git a/datastore/datastore/api/current.txt b/datastore/datastore/api/current.txt
new file mode 100644
index 0000000..38f7645
--- /dev/null
+++ b/datastore/datastore/api/current.txt
@@ -0,0 +1,38 @@
+// Signature format: 4.0
+package androidx.datastore {
+
+  public final class DataStoreFactoryKt {
+    method public static <T> androidx.datastore.core.DataStore<T> createDataStore(android.content.Context, String fileName, androidx.datastore.core.Serializer<T> serializer, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.core.DataMigration<T>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
+  }
+
+}
+
+package androidx.datastore.migrations {
+
+  public final class SharedPreferencesMigration<T> implements androidx.datastore.core.DataMigration<T> {
+    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, boolean deleteEmptyPreferences, kotlin.jvm.functions.Function2<? super T,? super kotlin.coroutines.Continuation<? super java.lang.Boolean>,?> shouldRunMigration, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
+    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, boolean deleteEmptyPreferences, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
+    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
+    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
+    method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public suspend Object? cleanUp(kotlin.coroutines.Continuation<? super kotlin.Unit> p) throws java.io.IOException;
+    method public suspend Object? migrate(T? currentData, kotlin.coroutines.Continuation<? super T> p);
+    method public suspend Object? shouldMigrate(T? currentData, kotlin.coroutines.Continuation<? super java.lang.Boolean> p);
+  }
+
+  public final class SharedPreferencesMigrationKt {
+  }
+
+  public final class SharedPreferencesView {
+    ctor public SharedPreferencesView(android.content.SharedPreferences prefs, java.util.Set<java.lang.String> keySet);
+    method public operator boolean contains(String key);
+    method public java.util.Map<java.lang.String,java.lang.Object> getAll();
+    method public boolean getBoolean(String key, boolean defValue);
+    method public float getFloat(String key, float defValue);
+    method public int getInt(String key, int defValue);
+    method public long getLong(String key, long defValue);
+    method public String? getString(String key, optional String? defValue);
+    method public java.util.Set<java.lang.String>? getStringSet(String key, optional java.util.Set<java.lang.String>? defValues);
+  }
+
+}
+
diff --git a/datastore/datastore/api/public_plus_experimental_current.txt b/datastore/datastore/api/public_plus_experimental_current.txt
new file mode 100644
index 0000000..38f7645
--- /dev/null
+++ b/datastore/datastore/api/public_plus_experimental_current.txt
@@ -0,0 +1,38 @@
+// Signature format: 4.0
+package androidx.datastore {
+
+  public final class DataStoreFactoryKt {
+    method public static <T> androidx.datastore.core.DataStore<T> createDataStore(android.content.Context, String fileName, androidx.datastore.core.Serializer<T> serializer, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.core.DataMigration<T>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
+  }
+
+}
+
+package androidx.datastore.migrations {
+
+  public final class SharedPreferencesMigration<T> implements androidx.datastore.core.DataMigration<T> {
+    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, boolean deleteEmptyPreferences, kotlin.jvm.functions.Function2<? super T,? super kotlin.coroutines.Continuation<? super java.lang.Boolean>,?> shouldRunMigration, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
+    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, boolean deleteEmptyPreferences, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
+    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
+    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
+    method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public suspend Object? cleanUp(kotlin.coroutines.Continuation<? super kotlin.Unit> p) throws java.io.IOException;
+    method public suspend Object? migrate(T? currentData, kotlin.coroutines.Continuation<? super T> p);
+    method public suspend Object? shouldMigrate(T? currentData, kotlin.coroutines.Continuation<? super java.lang.Boolean> p);
+  }
+
+  public final class SharedPreferencesMigrationKt {
+  }
+
+  public final class SharedPreferencesView {
+    ctor public SharedPreferencesView(android.content.SharedPreferences prefs, java.util.Set<java.lang.String> keySet);
+    method public operator boolean contains(String key);
+    method public java.util.Map<java.lang.String,java.lang.Object> getAll();
+    method public boolean getBoolean(String key, boolean defValue);
+    method public float getFloat(String key, float defValue);
+    method public int getInt(String key, int defValue);
+    method public long getLong(String key, long defValue);
+    method public String? getString(String key, optional String? defValue);
+    method public java.util.Set<java.lang.String>? getStringSet(String key, optional java.util.Set<java.lang.String>? defValues);
+  }
+
+}
+
diff --git a/datastore/datastore/api/res-current.txt b/datastore/datastore/api/res-current.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/datastore/datastore/api/res-current.txt
diff --git a/datastore/datastore/api/restricted_current.txt b/datastore/datastore/api/restricted_current.txt
new file mode 100644
index 0000000..38f7645
--- /dev/null
+++ b/datastore/datastore/api/restricted_current.txt
@@ -0,0 +1,38 @@
+// Signature format: 4.0
+package androidx.datastore {
+
+  public final class DataStoreFactoryKt {
+    method public static <T> androidx.datastore.core.DataStore<T> createDataStore(android.content.Context, String fileName, androidx.datastore.core.Serializer<T> serializer, optional androidx.datastore.core.handlers.ReplaceFileCorruptionHandler<T>? corruptionHandler, optional java.util.List<? extends androidx.datastore.core.DataMigration<T>> migrations, optional kotlinx.coroutines.CoroutineScope scope);
+  }
+
+}
+
+package androidx.datastore.migrations {
+
+  public final class SharedPreferencesMigration<T> implements androidx.datastore.core.DataMigration<T> {
+    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, boolean deleteEmptyPreferences, kotlin.jvm.functions.Function2<? super T,? super kotlin.coroutines.Continuation<? super java.lang.Boolean>,?> shouldRunMigration, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
+    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, boolean deleteEmptyPreferences, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
+    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, java.util.Set<java.lang.String>? keysToMigrate, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
+    ctor public SharedPreferencesMigration(android.content.Context context, String sharedPreferencesName, kotlin.jvm.functions.Function3<? super androidx.datastore.migrations.SharedPreferencesView,? super T,? super kotlin.coroutines.Continuation<? super T>,?> migrate);
+    method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public suspend Object? cleanUp(kotlin.coroutines.Continuation<? super kotlin.Unit> p) throws java.io.IOException;
+    method public suspend Object? migrate(T? currentData, kotlin.coroutines.Continuation<? super T> p);
+    method public suspend Object? shouldMigrate(T? currentData, kotlin.coroutines.Continuation<? super java.lang.Boolean> p);
+  }
+
+  public final class SharedPreferencesMigrationKt {
+  }
+
+  public final class SharedPreferencesView {
+    ctor public SharedPreferencesView(android.content.SharedPreferences prefs, java.util.Set<java.lang.String> keySet);
+    method public operator boolean contains(String key);
+    method public java.util.Map<java.lang.String,java.lang.Object> getAll();
+    method public boolean getBoolean(String key, boolean defValue);
+    method public float getFloat(String key, float defValue);
+    method public int getInt(String key, int defValue);
+    method public long getLong(String key, long defValue);
+    method public String? getString(String key, optional String? defValue);
+    method public java.util.Set<java.lang.String>? getStringSet(String key, optional java.util.Set<java.lang.String>? defValues);
+  }
+
+}
+
diff --git a/datastore/datastore/build.gradle b/datastore/datastore/build.gradle
new file mode 100644
index 0000000..904732d
--- /dev/null
+++ b/datastore/datastore/build.gradle
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import static androidx.build.dependencies.DependenciesKt.*
+import androidx.build.LibraryGroups
+import androidx.build.AndroidXExtension
+import androidx.build.Publish
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+
+plugins {
+    id("AndroidXPlugin")
+    id("com.android.library")
+    id("kotlin-android")
+}
+
+android {
+    sourceSets {
+        androidTest {
+            // Shared TestingSerializer between test and androidTest
+            kotlin.srcDirs += test.kotlin.srcDirs
+        }
+    }
+}
+
+dependencies {
+    api(KOTLIN_STDLIB)
+    api(KOTLIN_COROUTINES_CORE)
+    api("androidx.annotation:annotation:1.1.0")
+    api(project(":datastore:datastore-core"))
+
+    testImplementation(JUNIT)
+    testImplementation(KOTLIN_COROUTINES_TEST)
+    testImplementation(TRUTH)
+    testImplementation(project(":internal-testutils-truth"))
+
+    androidTestImplementation(JUNIT)
+    androidTestImplementation(KOTLIN_COROUTINES_TEST)
+    androidTestImplementation(TRUTH)
+    androidTestImplementation(project(":internal-testutils-truth"))
+    androidTestImplementation(ANDROIDX_TEST_RUNNER)
+    androidTestImplementation(ANDROIDX_TEST_CORE)
+}
+
+androidx {
+    name = "Android DataStore"
+    publish = Publish.SNAPSHOT_AND_RELEASE
+    mavenGroup = LibraryGroups.DATASTORE
+    inceptionYear = "2020"
+    description = "Android DataStore - contains the underlying store used by each serialization " +
+            "method along with components that require an Android dependency"
+    legacyDisableKotlinStrictApiMode = true
+}
+
+// Allow usage of Kotlin's @OptIn.
+tasks.withType(KotlinCompile).configureEach {
+    kotlinOptions {
+        freeCompilerArgs += ["-Xopt-in=kotlin.RequiresOptIn"]
+    }
+}
diff --git a/datastore/datastore-core/src/androidTest/AndroidManifest.xml b/datastore/datastore/src/androidTest/AndroidManifest.xml
similarity index 100%
rename from datastore/datastore-core/src/androidTest/AndroidManifest.xml
rename to datastore/datastore/src/androidTest/AndroidManifest.xml
diff --git a/datastore/datastore/src/androidTest/java/androidx/datastore/DataStoreFactoryTest.kt b/datastore/datastore/src/androidTest/java/androidx/datastore/DataStoreFactoryTest.kt
new file mode 100644
index 0000000..8bcb6fb
--- /dev/null
+++ b/datastore/datastore/src/androidTest/java/androidx/datastore/DataStoreFactoryTest.kt
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.datastore
+
+import android.content.Context
+import androidx.datastore.core.DataStoreFactory
+import androidx.test.core.app.ApplicationProvider
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.flow.first
+import kotlinx.coroutines.test.TestCoroutineScope
+import kotlinx.coroutines.test.runBlockingTest
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.rules.TemporaryFolder
+import java.io.File
+
+@kotlinx.coroutines.ExperimentalCoroutinesApi
+@kotlinx.coroutines.ObsoleteCoroutinesApi
+@kotlinx.coroutines.FlowPreview
+class DataStoreFactoryTest {
+
+    @get:Rule
+    val tmp = TemporaryFolder()
+
+    private lateinit var testFile: File
+    private lateinit var dataStoreScope: TestCoroutineScope
+    private lateinit var context: Context
+
+    @Before
+    fun setUp() {
+        testFile = tmp.newFile()
+        dataStoreScope = TestCoroutineScope()
+        context = ApplicationProvider.getApplicationContext()
+    }
+
+    @Test
+    fun testCreateWithContextAndName() = runBlockingTest {
+        val byte = 1
+
+        var store = context.createDataStore(
+            serializer = TestingSerializer(),
+            fileName = "my_settings.byte",
+            scope = dataStoreScope
+        )
+        store.updateData { 1 }
+
+        // Create it again and confirm it's still there
+        store = context.createDataStore(
+            serializer = TestingSerializer(),
+            fileName = "my_settings.byte",
+            scope = dataStoreScope
+        )
+        assertThat(store.data.first()).isEqualTo(byte)
+
+        // Check that the file name is context.filesDir + fileName
+        store = DataStoreFactory.create(
+            produceFile = {
+                File(context.filesDir, "datastore/my_settings.byte")
+            },
+            serializer = TestingSerializer(),
+            scope = dataStoreScope
+        )
+        assertThat(store.data.first()).isEqualTo(byte)
+    }
+}
\ No newline at end of file
diff --git a/datastore/datastore-core/src/test/java/androidx/datastore/TestingSerializer.kt b/datastore/datastore/src/androidTest/java/androidx/datastore/TestingSerializer.kt
similarity index 94%
copy from datastore/datastore-core/src/test/java/androidx/datastore/TestingSerializer.kt
copy to datastore/datastore/src/androidTest/java/androidx/datastore/TestingSerializer.kt
index 769529d..a873c95 100644
--- a/datastore/datastore-core/src/test/java/androidx/datastore/TestingSerializer.kt
+++ b/datastore/datastore/src/androidTest/java/androidx/datastore/TestingSerializer.kt
@@ -16,6 +16,8 @@
 
 package androidx.datastore
 
+import androidx.datastore.core.CorruptionException
+import androidx.datastore.core.Serializer
 import java.io.IOException
 import java.io.InputStream
 import java.io.OutputStream
diff --git a/datastore/datastore-core/src/androidTest/java/androidx/datastore/migrations/SharedPreferencesMigrationTest.kt b/datastore/datastore/src/androidTest/java/androidx/datastore/migrations/SharedPreferencesMigrationTest.kt
similarity index 97%
rename from datastore/datastore-core/src/androidTest/java/androidx/datastore/migrations/SharedPreferencesMigrationTest.kt
rename to datastore/datastore/src/androidTest/java/androidx/datastore/migrations/SharedPreferencesMigrationTest.kt
index cc67bd7..c7787b6 100644
--- a/datastore/datastore-core/src/androidTest/java/androidx/datastore/migrations/SharedPreferencesMigrationTest.kt
+++ b/datastore/datastore/src/androidTest/java/androidx/datastore/migrations/SharedPreferencesMigrationTest.kt
@@ -18,9 +18,9 @@
 
 import android.content.Context
 import android.content.SharedPreferences
-import androidx.datastore.DataMigration
-import androidx.datastore.DataStore
-import androidx.datastore.DataStoreFactory
+import androidx.datastore.core.DataMigration
+import androidx.datastore.core.DataStore
+import androidx.datastore.core.DataStoreFactory
 import androidx.datastore.TestingSerializer
 import androidx.test.core.app.ApplicationProvider
 import androidx.test.filters.MediumTest
diff --git a/datastore/datastore-core/src/main/AndroidManifest.xml b/datastore/datastore/src/main/AndroidManifest.xml
similarity index 100%
rename from datastore/datastore-core/src/main/AndroidManifest.xml
rename to datastore/datastore/src/main/AndroidManifest.xml
diff --git a/datastore/datastore/src/main/java/androidx/datastore/DataStoreFactory.kt b/datastore/datastore/src/main/java/androidx/datastore/DataStoreFactory.kt
new file mode 100644
index 0000000..52cbde9
--- /dev/null
+++ b/datastore/datastore/src/main/java/androidx/datastore/DataStoreFactory.kt
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.datastore
+
+import android.content.Context
+import androidx.datastore.core.DataMigration
+import androidx.datastore.core.DataStore
+import androidx.datastore.core.DataStoreFactory
+import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
+import androidx.datastore.core.Serializer
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.SupervisorJob
+import java.io.File
+
+/**
+ * Create an instance of SingleProcessDataStore. The user is responsible for ensuring that
+ * there is never more than one instance of SingleProcessDataStore acting on a file at a time.
+ *
+ * @param fileName the filename relative to Context.filesDir that DataStore acts on. The File is
+ * obtained by calling File(context.filesDir, fileName). No two instances of DataStore should
+ * act on the same file at the same time.
+ * @param corruptionHandler The corruptionHandler is invoked if DataStore encounters a
+ * [androidx.datastore.CorruptionException] when attempting to read data. CorruptionExceptions are
+ * thrown by
+ * serializers when data can not be de-serialized.
+ * @param migrations are run before any access to data can occur. Each producer and migration
+ * may be run more than once whether or not it already succeeded (potentially because another
+ * migration failed or a write to disk failed.)
+ * @param scope The scope in which IO operations and transform functions will execute.
+ */
+public fun <T> Context.createDataStore(
+    fileName: String,
+    serializer: Serializer<T>,
+    corruptionHandler: ReplaceFileCorruptionHandler<T>? = null,
+    migrations: List<DataMigration<T>> = listOf(),
+    scope: CoroutineScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
+): DataStore<T> =
+    DataStoreFactory.create(
+        produceFile = { File(this.filesDir, "datastore/$fileName") },
+        serializer = serializer,
+        corruptionHandler = corruptionHandler,
+        migrations = migrations,
+        scope = scope
+    )
diff --git a/datastore/datastore-core/src/main/java/androidx/datastore/migrations/SharedPreferencesMigration.kt b/datastore/datastore/src/main/java/androidx/datastore/migrations/SharedPreferencesMigration.kt
similarity index 97%
rename from datastore/datastore-core/src/main/java/androidx/datastore/migrations/SharedPreferencesMigration.kt
rename to datastore/datastore/src/main/java/androidx/datastore/migrations/SharedPreferencesMigration.kt
index 65c47a2..c0d932e 100644
--- a/datastore/datastore-core/src/main/java/androidx/datastore/migrations/SharedPreferencesMigration.kt
+++ b/datastore/datastore/src/main/java/androidx/datastore/migrations/SharedPreferencesMigration.kt
@@ -16,9 +16,10 @@
 
 package androidx.datastore.migrations
 
+import android.annotation.SuppressLint
 import android.content.Context
 import android.content.SharedPreferences
-import androidx.datastore.DataMigration
+import androidx.datastore.core.DataMigration
 import java.io.File
 import java.io.IOException
 import kotlin.jvm.Throws
@@ -111,6 +112,8 @@
         keySet.clear()
     }
 
+    // TODO(b/170429111): Fix the unsafe new API call.
+    @SuppressLint("UnsafeNewApiCall")
     private fun deleteSharedPreferences(context: Context, name: String) {
         if (android.os.Build.VERSION.SDK_INT >= 24) {
             if (!context.deleteSharedPreferences(name)) {
diff --git a/settings.gradle b/settings.gradle
index 28d4aa4..55d08c3 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -270,6 +270,7 @@
 includeProject(":core:core-ktx", "core/core-ktx", [BuildType.MAIN])
 includeProject(":cursoradapter:cursoradapter", "cursoradapter/cursoradapter", [BuildType.MAIN])
 includeProject(":customview:customview", "customview/customview", [BuildType.MAIN])
+includeProject(":datastore:datastore", "datastore/datastore", [BuildType.MAIN])
 includeProject(":datastore:datastore-core", "datastore/datastore-core", [BuildType.MAIN])
 includeProject(":datastore:datastore-preferences", "datastore/datastore-preferences", [BuildType.MAIN])
 includeProject(":datastore:datastore-preferences:datastore-preferences-proto", "datastore/datastore-preferences/datastore-preferences-proto", [BuildType.MAIN])