title: ./gradlew test connectedAndroidTest erases my getFilesDir() folder
body: <p>I'm writing a Room database into my getFilesDir() folder. (Writing the database onto the removable SD card is apparently going to require some <em>major</em> research!)</p>
  
  <p>When I manually run my app, I want to write some records and leave them in the database, so I don't need to keep writing them again. When I run my tests, I switch the database name from "*.dat" to "_test.dat" (think Ruby on Rails's or Django's "environments" system). The tests are free to erase records.</p>
  
  <p>This system works when I manually tweezer each test in Android Studio to run it. But when I run everything in a batch, in <code>gradlew</code>, something erases the "*.dat" version of the database. This means I must constantly manually repopulate the database, each time I manually test.</p>
  
  <p>What inside <code>gradlew</code> is erasing the contents of my getFilesDir() folder? And how (without figuring out how to use "external" storage), do I defeat it?</p>
  
  <p>Code samples available on request, but it's all just generic stuff. Switching to getExternalFilesDir() does not fix the problem. StackOverflow said to try <code>./gradlew test connectedAndroidTest -x uninstallAndroidTest</code>, but there's no <code>uninstallAndroidTest</code> task.</p>
  
  <hr>
  
  <p>The top level <code>build.gradle</code>:</p>
  
  <pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.
  
  buildscript {
      repositories {
          google()
          jcenter()
  
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:3.5.2'
  
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  
  allprojects {
      repositories {
          google()
          jcenter()
  
      }
  }
  
  task clean(type: Delete) {
      delete rootProject.buildDir
  }
  
  tasks.withType(Test) {
    testLogging {
      exceptionFormat "full"
      events "started", "skipped", "passed", "failed"
      showStandardStreams true
    }
  }
  </code></pre>
  
  <p>The <code>app/build.gradle</code>:</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 29
      buildToolsVersion "29.0.2"
      defaultConfig {
          applicationId "com.allflat.planarinfinity"
          minSdkVersion 26
          targetSdkVersion 29
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
          }
      }
  //    packagingOptions {
  //        exclude 'META-INF/DEPENDENCIES'
  //        exclude 'META-INF/LICENSE'
  //        exclude 'META-INF/LICENSE.txt'
  //        exclude 'META-INF/license.txt'
  //        exclude 'META-INF/NOTICE'
  //        exclude 'META-INF/NOTICE.txt'
  //        exclude 'META-INF/notice.txt'
  //        exclude 'META-INF/ASL2.0'
  //        exclude 'META-INF/INDEX.LIST'
  //    }
  }
  
  dependencies {
      implementation fileTree(dir: 'libs', include: ['*.jar'])
      implementation 'androidx.appcompat:appcompat:1.1.0'
      implementation 'androidx.legacy:legacy-support-v4:1.0.0'
      implementation 'com.google.android.material:material:1.0.0'
      testImplementation 'junit:junit:4.12'
     // testImplementation 'org.mockito:mockito-core:2.19.0'
      testImplementation 'androidx.arch.core:core-testing:2.1.0'
      androidTestImplementation 'org.powermock:powermock-core:2.0.2'
      androidTestImplementation 'org.powermock:powermock-module-junit4:2.0.2'
      androidTestImplementation 'org.powermock:powermock-api-easymock:2.0.2'
      androidTestImplementation 'androidx.test:core:1.2.0'
      androidTestImplementation 'androidx.test.ext:junit:1.1.2-alpha02'
      androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02'
      androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.2.0'
      androidTestImplementation 'androidx.test:rules:1.2.0'
  //    androidTestImplementation 'androidx.test.platform.app:'
      implementation 'androidx.room:room-runtime:2.2.0'
      annotationProcessor 'androidx.room:room-compiler:2.2.0'
      testImplementation 'androidx.test:core:1.2.0'
      androidTestImplementation 'com.android.support.test:runner:1.0.2'
      androidTestImplementation 'com.android.support.test:rules:1.0.2'
      androidTestImplementation 'org.easymock:easymock:4.0.2'
  //    androidTestImplementation 'org.mockito:mockito-core:2.19.0'
  }
  </code></pre>
  
  <hr>
  
  <p>It's the 'uninstall' in here:</p>
  
  <p><a href="https://android.googlesource.com/platform/tools/base/+/8d969614b7beca74e4d17f2d1c5956e75053f7ce/build-system/builder/src/main/java/com/android/builder/internal/testing/SimpleTestCallable.java" rel="noreferrer">https://android.googlesource.com/platform/tools/base/+/8d969614b7beca74e4d17f2d1c5956e75053f7ce/build-system/builder/src/main/java/com/android/builder/internal/testing/SimpleTestCallable.java</a></p>
  
  <p>Could someone take it out? It's annoying everyone.</p>