I have a flutter application that fetches images from internal storage, the permission for read/write are already handled using storage_path plugin in flutter.
Also write permission is given at AndroidManifest.xml file
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
The methodchannel code looks like this: filename example: /storage/emulated/0/Pictures/Screenshots/Screenshot_20201116-224238_Pixel_Launcher.png
private val CHANNEL = "com.rs.gallery/gallery"
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { call, result ->
if (call.method == "Delete") {
val file = call.argument<String>("file")
Log.d("method channel", file)
val f = File(file)
if (f.exists()) {
val res: Boolean = f.delete()
Log.d(file, res.toString())
} else {
Log.d(file, "NOT FOUND")
}
}
}
}
The output of the delete method is false and unable to delete the file. What am I missing? Or is the permission for deleting file from internal storage to be handled separately?