{"id":32417819,"url":"https://github.com/helloukey/react-native-mediastore","last_synced_at":"2026-04-17T09:31:42.585Z","repository":{"id":260257841,"uuid":"880788480","full_name":"helloukey/react-native-mediastore","owner":"helloukey","description":"Easily delete photos and videos from android using new scoped storage MediaStore API.","archived":false,"fork":false,"pushed_at":"2024-11-11T14:15:30.000Z","size":34,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-23T09:09:32.617Z","etag":null,"topics":["react-native-delete-media","react-native-media","react-native-media-delete","react-native-media-library","react-native-media-manager","react-native-mediastore"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@kunalukey/react-native-mediastore","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/helloukey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-30T11:08:55.000Z","updated_at":"2025-08-25T13:35:37.000Z","dependencies_parsed_at":"2024-10-30T12:40:33.234Z","dependency_job_id":null,"html_url":"https://github.com/helloukey/react-native-mediastore","commit_stats":null,"previous_names":["helloukey/react-native-mediastore"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/helloukey/react-native-mediastore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloukey%2Freact-native-mediastore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloukey%2Freact-native-mediastore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloukey%2Freact-native-mediastore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloukey%2Freact-native-mediastore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/helloukey","download_url":"https://codeload.github.com/helloukey/react-native-mediastore/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helloukey%2Freact-native-mediastore/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31923093,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T09:10:15.403Z","status":"ssl_error","status_checked_at":"2026-04-17T09:10:14.455Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react-native-delete-media","react-native-media","react-native-media-delete","react-native-media-library","react-native-media-manager","react-native-mediastore"],"created_at":"2025-10-25T16:21:23.572Z","updated_at":"2026-04-17T09:31:42.566Z","avatar_url":"https://github.com/helloukey.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# `@kunalukey/react-native-mediastore`\n\n## NOTE: This module extends the [react-native-delete-media](https://www.npmjs.com/package/react-native-delete-media) module to support deleting videos as well\n\n**_react-native-mediastore_** is a react native module used to delete media on android using the new scoped storage. **_It only supports Android_**.\n\nIt uses the native `MediaStore.createDeleteRequest` function to launch the android activity responsible for asking the user permission to delete a media file.\n\n## Getting started\n\n### Installing\n\n`$ npm install @kunalukey/react-native-mediastore`\n\n### Library configuration\n\n1. Append the following lines to `android/settings.gradle`:\n\n   ```gradle\n   include 'kunalukey_react-native-mediastore'\n   project(':kunalukey_react-native-mediastore').projectDir = new File(rootProject.projectDir, '../node_modules/@kunalukey/react-native-mediastore/android')\n   ```\n\n2. Insert the following lines inside the dependencies block in `android/app/build.gradle`:\n\n   ```gradle\n     implementation project(':kunalukey_react-native-mediastore')\n   ```\n\n3. Add the following lines to your imports in `android/app/src/main/java/com/[projectname]/MainActivity.java`:\n\n   ```java\n       import com.kunalukey.mediastore.DeleteMediaModule;\n       import android.os.Bundle;\n   ```\n\n4. Create the `OnCreate` method in `MainActivity.java`, if you already have an `OnCreate` function just add the init line:\n\n   ```java\n   @Override\n   public void onCreate(Bundle savedInstanceState) {\n       super.onCreate(savedInstanceState);\n       DeleteMediaModule.init(this);\n   }\n   ```\n\n    Your `MainActivity.java` file should look like this:\n\n    ```java\n    import com.facebook.react.ReactActivity;\n    import com.facebook.react.ReactActivityDelegate;\n    import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;\n    import com.facebook.react.defaults.DefaultReactActivityDelegate;\n\n    import com.kunalukey.mediastore.DeleteMediaModule;\n    import android.os.Bundle;\n\n    public class MainActivity extends ReactActivity {\n\n    @Override\n      public void onCreate(Bundle savedInstanceState) {\n          super.onCreate(savedInstanceState);\n          DeleteMediaModule.init(this);\n      }\n    ...\n    ...\n    }\n\n    ```\n\n5. Make sure to rebuild using `yarn android`.\n\n### Linking\n\nThis module was created using the new Turbo Native Modules.\nIt needs to have the New Architecture enabled in the `android/gradle.properties` file.\n\nIf you're project is not using New Architecture, you'll need to link the library manually.\n\nTo do so:\n\n1. Follow the steps in the [`Library configuration`](#library-configuration) section.\n\n2. In the `android/app/src/main/java/com/[projectname]/MainApplication.java` file, add:\n\n    * `import com.kunalukey.mediastore.DeleteMediaPackage;` to the list of imports at the top of the file.\n\n    * `packages.add(new DeleteMediaPackage());` to the `getPackages()` method.\n\n**Note:** If you the this error while trying to use the module `[TypeError: Cannot read property 'deletePhotos' / 'deleteVideos' of null]` you probably need to manually link it.\n\n### Permissions\n\nYou will need to add the `WRITE_EXTERNAL_STORAGE` permission to your android manifest\n\n```manifest\n\u003cmanifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e\n\n    \u003cuses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/\u003e\n\n    \u003capplication\n      ...\n    \u003c/application\u003e\n\u003c/manifest\u003e\n```\n\nAnd make sure to request it before calling any functions from this module.\n\n## Usage\n\nHere is a simple example of using the library.\n\n```typescript\nimport { PermissionsAndroid, Platform } from \"react-native\";\nimport { DeleteMedia, ErrorCodes } from \"@kunalukey/react-native-mediastore\";\n\nasync function hasAndroidPermission() {\n  const permission = PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE;\n\n  const hasPermission = await PermissionsAndroid.check(permission);\n  if (hasPermission) {\n    return true;\n  }\n\n  const status = await PermissionsAndroid.request(permission);\n  return status === \"granted\";\n}\n\nasync function performDelete() {\n  if (Platform.OS !== \"android\") {\n    return;\n  }\n\n  if (!(await hasAndroidPermission())) {\n    return;\n  }\n\n  const photoURI = \"file:///storage/emulated/0/DCIM/Camera/photo.jpg\";\n  const videoURI = \"file:///storage/emulated/0/DCIM/Camera/video.mp4\";\n\n  // Delete photo\n  DeleteMedia.deletePhotos([uri])\n    .then(() =\u003e {\n      console.log(\"Image deleted\");\n    })\n    .catch((e) =\u003e {\n      const message = e.message;\n      const code: ErrorCodes = e.code;\n\n      switch (code) {\n        case \"ERROR_USER_REJECTED\":\n          console.log(\"Image deletion denied by user\");\n          break;\n        default:\n          console.log(message);\n          break;\n      }\n    });\n\n  // Delete video  \n  DeleteMedia.deleteVideos([uri])\n    .then(() =\u003e {\n      console.log(\"Video deleted\");\n    })\n    .catch((e) =\u003e {\n      const message = e.message;\n      const code: ErrorCodes = e.code;\n\n      switch (code) {\n        case \"ERROR_USER_REJECTED\":\n          console.log(\"Video deletion denied by user\");\n          break;\n        default:\n          console.log(message);\n          break;\n      }\n    });\n}\n```\n\n## Methods\n\n### `deletePhotos()`\n\n```typescript\n    DeleteMedia.deletePhotos(Array\u003cstring\u003e);\n```\n\nThis function asks the android OS to delete a list of photos.\n\nIt takes in an array of uris strings. Theses strings must be valid\nuris to a local images, such as `file:///storage/emulated/0/DCIM/Camera/photo.jpg`\n\nThe function will fail if at least one of the uris is not valid or is not found.\n\nIt returns a promise that resolves if all the photos was deleted and rejects otherwise.\n\nWhen rejected it returns an error object of type `{code: ErrorCodes, message: string}`.\n\nThe list of possible error codes is:\n\n* `\"ERROR_WRITE_EXTERNAL_STORAGE_PERMISSION_NEEDED\"`\n\n  Permission to write to external storage is not granted.\n\n* `\"ERROR_URIS_NOT_FOUND\"`\n\n  One or more uris are invalid or not found.\n\n* `\"ERROR_USER_REJECTED\"`\n\n  User rejected the delete operation.\n\n* `\"ERROR_URIS_PARAMETER_NULL\"`\n\n  List of uris passed to `deletePhotos` is `undefined` or `null`\n\n* `\"ERROR_URIS_PARAMETER_INVALID\"`\n\n  List of uris passed to `deletePhotos` is not valid, it should be an array of strings.\n\n* `\"ERROR_MODULE_NOT_INITIALIZED\"`\n\n  The module was not initialized correctly, please follow the steps in [`Library configuration`](#library-configuration)\n\n* `\"ERROR_UNEXPECTED\"`\n\n  Unexpected error. Report it if encountered in **[`Issues`](https://github.com/helloukey/react-native-mediastore/issues)**.\n\n### `deleteVideos()`\n\n```typescript\n    DeleteMedia.deleteVideos(Array\u003cstring\u003e);\n```\n\nThis function asks the android OS to delete a list of videos.\n\nIt takes in an array of uris strings. Theses strings must be valid\nuris to a local videos, such as `file:///storage/emulated/0/DCIM/Camera/video.mp4`\n\nThe function will fail if at least one of the uris is not valid or is not found.\n\nIt returns a promise that resolves if all the videos was deleted and rejects otherwise.\n\nWhen rejected it returns an error object of type `{code: ErrorCodes, message: string}`.\n\nThe list of possible error codes is:\n\n* `\"ERROR_WRITE_EXTERNAL_STORAGE_PERMISSION_NEEDED\"`\n\n  Permission to write to external storage is not granted.\n\n* `\"ERROR_URIS_NOT_FOUND\"`\n\n  One or more uris are invalid or not found.\n\n* `\"ERROR_USER_REJECTED\"`\n\n  User rejected the delete operation.\n\n* `\"ERROR_URIS_PARAMETER_NULL\"`\n\n  List of uris passed to `deleteVideos` is `undefined` or `null`\n\n* `\"ERROR_URIS_PARAMETER_INVALID\"`\n\n  List of uris passed to `deleteVideos` is not valid, it should be an array of strings.\n\n* `\"ERROR_MODULE_NOT_INITIALIZED\"`\n\n  The module was not initialized correctly, please follow the steps in [`Library configuration`](#library-configuration)\n\n* `\"ERROR_UNEXPECTED\"`\n\n  Unexpected error. Report it if encountered in **[`Issues`](https://github.com/helloukey/react-native-mediastore/issues)**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelloukey%2Freact-native-mediastore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhelloukey%2Freact-native-mediastore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelloukey%2Freact-native-mediastore/lists"}