diff --git a/docs/assets/databases-plugin-1.png b/docs/assets/databases-plugin-1.png new file mode 100644 index 000000000..76115c140 Binary files /dev/null and b/docs/assets/databases-plugin-1.png differ diff --git a/docs/assets/databases-plugin-2.png b/docs/assets/databases-plugin-2.png new file mode 100644 index 000000000..c4f06a13c Binary files /dev/null and b/docs/assets/databases-plugin-2.png differ diff --git a/docs/features/databases-plugin.md b/docs/features/databases-plugin.md new file mode 100644 index 000000000..ef5fcdfb2 --- /dev/null +++ b/docs/features/databases-plugin.md @@ -0,0 +1,13 @@ +--- +id: databases-plugin +title: Databases +--- + +→ [See setup instructions for the Databases plugin](setup/databases-plugin.md) + +The Databases plugin provides developers with read access to their databases: browse the data, see your table's structure and its indexes. + +![Databases Plugin 1](/docs/assets/databases-plugin-1.png) +![Databases Plugin 2](/docs/assets/databases-plugin-2.png) + +Note: this plugin is only available for Android. diff --git a/docs/setup/databases-plugin.md b/docs/setup/databases-plugin.md new file mode 100644 index 000000000..79973b9da --- /dev/null +++ b/docs/setup/databases-plugin.md @@ -0,0 +1,63 @@ +--- +id: databases-plugin +title: Databases Plugin Setup +sidebar_label: Databases +--- + +To use the databases plugin, you need to add the plugin to your Flipper client instance. The plugin is currently only available for Android. + +## Android + +Instantiate and add the plugin in `FlipperClient`. +```java +import com.facebook.flipper.plugins.crashreporter.DatabasesPlugin; + +client.addPlugin(new DatabasesFlipperPlugin(context)); +``` + +By default it will list all sqlite databases returned by the context. If you are storing a sqlite database somewhere else, you can specify a `File` to it: + +```java +client.addPlugin(new DatabasesFlipperPlugin(new SqliteDatabaseDriver(context, new SqliteDatabaseProvider() { + @Override + public List getDatabaseFiles() { + List databaseFiles = new ArrayList<>(); + for (String databaseName : context.databaseList()) { + databaseFiles.add(context.getDatabasePath(databaseName)); + } + databaseFiles.add("...path_to_your_db...") + return databaseFiles; + } +}))); +``` + +If you use a different type of database other than sqlite, you can implement a driver to be able to access it via Flipper. + +```java +client.addPlugin(new DatabasesFlipperPlugin(new DatabaseDriver(context) { + @Override + public List getDatabases() { + return null; + } + + @Override + public List getTableNames(DatabaseDescriptor databaseDescriptor) { + return null; + } + + @Override + public DatabaseGetTableDataResponse getTableData(DatabaseDescriptor databaseDescriptor, String table, String order, boolean reverse, int start, int count) { + return null; + } + + @Override + public DatabaseGetTableStructureResponse getTableStructure(DatabaseDescriptor databaseDescriptor, String table) { + return null; + } + + @Override + public DatabaseExecuteSqlResponse executeSQL(DatabaseDescriptor databaseDescriptor, String query) { + return null; + } + })); +``` \ No newline at end of file diff --git a/website/i18n/en.json b/website/i18n/en.json index b501f9363..fdb993211 100644 --- a/website/i18n/en.json +++ b/website/i18n/en.json @@ -63,6 +63,9 @@ "features/crash-reporter-plugin": { "title": "Crash Reporter" }, + "features/databases-plugin": { + "title": "Databases" + }, "features/index": { "title": "Features" }, @@ -94,6 +97,10 @@ "title": "Crash Reporter Setup", "sidebar_label": "Crash Reporter" }, + "setup/databases-plugin": { + "title": "Databases Plugin Setup", + "sidebar_label": "Databases" + }, "setup/layout-plugin": { "title": "Layout Inspector Setup", "sidebar_label": "Layout Inspector" @@ -128,6 +135,9 @@ "tutorial/intro": { "title": "Intro" }, + "tutorial/ios": { + "title": "Building an iOS Plugin" + }, "tutorial/js-custom": { "title": "Building Custom UI", "sidebar_label": "Custom UI" diff --git a/website/sidebars.json b/website/sidebars.json index 7c9715315..44a65b3d1 100644 --- a/website/sidebars.json +++ b/website/sidebars.json @@ -5,6 +5,7 @@ "features/logs-plugin", "features/layout-plugin", "features/network-plugin", + "features/databases-plugin", "features/sandbox-plugin", "features/shared-preferences-plugin", "features/leak-canary-plugin", @@ -20,6 +21,7 @@ "Plugin Setup": [ "setup/layout-plugin", "setup/network-plugin", + "setup/databases-plugin", "setup/sandbox-plugin", "setup/shared-preferences-plugin", "setup/leak-canary-plugin",