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

Method canWrite

src/plugins/sdcard/src/android/SDcard.java:1147–1165  ·  view source on GitHub ↗
(Uri uri)

Source from the content-addressed store, hash-verified

1145 }
1146
1147 public boolean canWrite(Uri uri) {
1148 boolean canWrite = false;
1149 try {
1150 // if the file is not writable this throws a SecurityException
1151 OutputStream os = context
1152 .getContentResolver()
1153 .openOutputStream(uri, "wa");
1154
1155 if (os == null) return false;
1156
1157 os.close(); // we don't actually want to write anything, so we close immediately
1158 canWrite = true;
1159 } catch (
1160 SecurityException | IllegalArgumentException | IOException ignored
1161 ) {
1162 // if we don't have write-permission or the file doesn't exist, canWrite can stay on false
1163 }
1164 return canWrite;
1165 }
1166}
1167
1168class MyFileObserver extends FileObserver {

Callers 4

onActivityResultMethod · 0.95
runMethod · 0.95
includeFileMethod · 0.80

Calls 1

closeMethod · 0.65

Tested by

no test coverage detected