Support in the Android app for SAF (Storage Access Framework) on Android for read/write to network drives directly

Currently local Android folders are supported, but network drives, even if available to the device, are not supported by LogSeq. Adding support for SAF (Storage Access Framework), in order to be able to load/save directly from network drives installed on your phone (GDrive/OneDrive/…) would be good.

protected void onCreate(Bundle savedInstanceState) {

// Create an intent to start the SAF file picker.
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);

// Set the intent's data and mimeType parameters to the desired GDrive folder and file type.

// Start the intent and wait for the user to select a file.
startActivityForResult(intent, REQUEST_CODE_OPEN_DOCUMENT);


protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

// Check if the user selected a file.
if (requestCode == REQUEST_CODE_OPEN_DOCUMENT && resultCode == RESULT_OK && data != null && data.getData() != null) {

    // Get the selected file's URI.
    Uri uri = data.getData();

    // Open the file using a FileInputStream.
    try (FileInputStream fileInputStream = getContentResolver().openInputStream(uri)) {

        // Read data from the file using a BufferedReader.
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fileInputStream));
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            Log.d("MainActivity", line);
    } catch (IOException e) {
        Log.e("MainActivity", "Error reading file", e);


private static final int REQUEST_CODE_OPEN_DOCUMENT = 1;

Archived since its a duplicate.