AngelEngineering / nativescript-plugins

Plugins for Nativescript Applications
Apache License 2.0
5 stars 3 forks source link

Nativescript Filepicker don't show any local files #20

Open AAlex-11 opened 3 months ago

AAlex-11 commented 3 months ago

My application need to create and uploading JSON file. Application definitely created file - I can see it in Android studio, Than I try to read the same file by my application. But I can not access to to files on CD-card.

ShareFileProvider-05312024_003622_1

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"  />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
    android:requestLegacyExternalStorage="true"
    android:name="com.tns.NativeScriptApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
    android:hardwareAccelerated="true">
    <provider
        android:name="androidx.core.content.FileProvider"
        android:authorities="${applicationId}.fileprovider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths" />
    </provider>
    <activity
        android:name="com.tns.NativeScriptActivity"
             ....

Additionally I have configured file provider. I use Android emulator API 30 (Android 11). Very strange, but in debugger I see Device.sdkVersion as undefined value. What I need more to receive access to my files? And what the best extension for my JSON file to minimum permission issues?

drangelod commented 1 month ago

You'll need to ensure the file is present somewhere visible to the Android File Picker, such as the device's Download directory. If you just need to use the file in the screenshot from NS code, you should be able to open/read/etc. using the file path as it resides in the app's sandboxed directory.