MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / getStorageVolumes

Method getStorageVolumes

src/plugins/sdcard/src/android/SDcard.java:271–313  ·  view source on GitHub ↗
(CallbackContext callback)

Source from the content-addressed store, hash-verified

269 }
270
271 public void getStorageVolumes(CallbackContext callback) {
272 try {
273 JSONArray result = new JSONArray();
274
275 if (SDK_INT >= 24) {
276 for (StorageVolume volume : this.storageManager.getStorageVolumes()) {
277 String name = volume.getDescription(this.context);
278 String uuid = volume.getUuid();
279 JSONObject volumeData = new JSONObject();
280 if (name != null && uuid != null) {
281 volumeData.put("uuid", uuid);
282 volumeData.put("name", name);
283
284 if (SDK_INT >= 30) {
285 File file = volume.getDirectory();
286 String path = file.getAbsolutePath();
287 volumeData.put("path", path);
288 }
289
290 result.put(volumeData);
291 }
292 }
293 } else {
294 File file = Environment.getExternalStorageDirectory();
295 if (
296 Environment.getExternalStorageState(file) == Environment.MEDIA_MOUNTED
297 ) {
298 String name = file.getName();
299 String path = file.getPath();
300 String absolutePath = file.getAbsolutePath();
301 JSONObject volumeData = new JSONObject();
302 volumeData.put("name", name);
303 volumeData.put("path", path);
304 volumeData.put("absolutePath", absolutePath);
305 result.put(volumeData);
306 }
307 }
308
309 callback.success(result);
310 } catch (JSONException e) {
311 callback.error(e.toString());
312 }
313 }
314
315 public void getStorageAccess(String SDCardUUID, CallbackContext callback) {
316 Intent intent = null;

Callers 2

executeMethod · 0.95
getStorageAccessMethod · 0.80

Calls 5

putMethod · 0.80
successMethod · 0.80
getPathMethod · 0.65
errorMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected