UNPKG

expo-sdcard-detector

Version:

Expo plugin to detect SD card storage paths on Android

17 lines (14 loc) 526 B
import { NativeModules, Platform } from 'react-native'; const { SDCardDetector } = NativeModules; export async function getExternalStoragePaths(): Promise<string[]> { if (!SDCardDetector || typeof SDCardDetector.getExternalStoragePaths !== 'function') { return []; } try { const result = await SDCardDetector.getExternalStoragePaths(); return Platform.OS === 'android' ? JSON.parse(result) : []; } catch (error) { console.warn("Error retrieving external storage paths:", error); return []; } }