0

I have been trying to read files or write files in Android file system. My project is developed in AngularJS and converting it to APK using Cordova. When I install the app, it does not ask for file system permissions nor it is able to read or write files. It works in IDE but not in mobile. What can be the solution ?

1 Answer 1

0

You should call checkPermission and requestPermissions for WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE.

import { AndroidPermissions } from '@awesome-cordova-plugins/android-permissions/ngx';

constructor(private androidPermissions: AndroidPermissions) { }
   
this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.WRITE_EXTERNAL_STORAGE).then(
  result => console.log('Has permission?',result.hasPermission),
  err => this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.WRITE_EXTERNAL_STORAGE)
);

this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE, this.androidPermissions.PERMISSION.WRITE_EXTERNAL_STORAGE]);

See https://github.com/NeoLSN/cordova-plugin-android-permissions

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.