/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

package com.facebook.flipper.plugins.databases.impl;

import android.content.Context;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class DefaultSqliteDatabaseProvider implements SqliteDatabaseProvider {

  private Context context;

  public DefaultSqliteDatabaseProvider(Context context) {
    this.context = context;
  }

  @Override
  public List<File> getDatabaseFiles() {
    List<File> databaseFiles = new ArrayList<>();
    for (String databaseName : context.databaseList()) {
      databaseFiles.add(context.getDatabasePath(databaseName));
    }
    return databaseFiles;
  }
}

@@ -424,383 +424,1470 @@
 r %7B%0A
-%0A  private Context context;%0A%0A  public DefaultSqliteDatabaseProvider(Context context) %7B%0A    this.context = context;%0A  %7D%0A%0A  @Override%0A  public List%3CFile%3E getDatabaseFiles() %7B%0A    List%3CFile%3E databaseFiles = new ArrayList%3C%3E();%0A    for (String databaseName : context.databaseList()) %7B%0A      databaseFiles.add(context.getDatabasePath(databaseName));%0A    %7D%0A    return databaseFiles;
+  private static final int MAX_RECURSIVE_TRAVERSAL_DEPTH = 5;%0A  private static final String DB_EXTENSION = %22.db%22;%0A%0A  private final int fileDirectoryRecursiveDepth;%0A  private final Context context;%0A%0A  public DefaultSqliteDatabaseProvider(Context context) %7B%0A    this(context, MAX_RECURSIVE_TRAVERSAL_DEPTH);%0A  %7D%0A%0A  public DefaultSqliteDatabaseProvider(Context context, int fileDirectoryRecursiveDepth) %7B%0A    this.context = context;%0A    this.fileDirectoryRecursiveDepth = fileDirectoryRecursiveDepth;%0A  %7D%0A%0A  @Override%0A  public List%3CFile%3E getDatabaseFiles() %7B%0A    List%3CFile%3E databaseFiles = new ArrayList%3C%3E();%0A    for (String databaseName : context.databaseList()) %7B%0A      databaseFiles.add(context.getDatabasePath(databaseName));%0A    %7D%0A    addDatabaseFilesRecursively(%0A        new File(context.getFilesDir().getPath()),%0A        0,%0A        DB_EXTENSION,%0A        fileDirectoryRecursiveDepth,%0A        databaseFiles);%0A    return databaseFiles;%0A  %7D%0A%0A  private static void addDatabaseFilesRecursively(%0A      File directory, int depth, String dbExtension, int maxDepth, List%3CFile%3E dbFiles) %7B%0A    if (depth %3E= maxDepth) %7B%0A      return;%0A    %7D%0A    File%5B%5D files = directory.listFiles();%0A    if (files != null) %7B%0A      for (File f : files) %7B%0A        if (f.isFile() && f.getPath().endsWith(dbExtension)) %7B%0A          dbFiles.add(f);%0A        %7D else if (f.isDirectory()) %7B%0A          addDatabaseFilesRecursively(f, depth + 1, dbExtension, maxDepth, dbFiles);%0A        %7D%0A      %7D%0A    %7D
 %0A  %7D

Add databases under /files to the list of databases visible by default in Flipper Database Plugin