Check whether file exist in mobile storage or not

i am using file plugin . although files are in mobile storage and loading on device image src but
if i use this code showing “files not found”.
ionic 2.2.0

 for (let i = 0; i < data.rows.length; i++) {
            console.log(data.rows.item(i).local)
            File.checkFile(cordova.file.dataDirectory, data.rows.item(i).local).then(
              (files) => {
                console.log("files found" + files)
                resolve()
              }
            ).catch(
              (err) => {
                console.log("files not found ")
              }
              );

my file path is like this

“file:///storage/emulated/0/Android/data/com.ionicframework.schoolmgtsystem274373/image_1.jpg”

there was mistake in my side because in this it should be
File.checkFile(filepath, filename).
this is working for me

 for (let i = 0; i < data.rows.length; i++) {
            console.log(data.rows.item(i).local)
 let path: string = data.rows.item(i).local;
            // path=path.split('//')[1];
            console.log(data.rows.item(i).local)
            let filepath = path.substring(0, path.lastIndexOf('/') + 1);
            let filename = path.substring(path.lastIndexOf('/') + 1, path.length);
            File.checkFile(filepath, filename).then(
              (files) => {
                console.log("files found" + files)
              }
            ).catch(
              (err) => {
                console.log("files not found ")
              }
              );
3 Likes