Is the internal file automatically deleted?

My app copies external captured photos to internal storage. Gradually or immediately, the file is uploaded to a server in the online world. There are certain cases where the file to be loaded is missing, resulting in a FileNotFoundException. 78% of cases happened in Xiaomi devices.

Is it because of any memory cleaning application? Or is there any solution associated? Even an appreciated view of a possible problem will be appreciated.

Non-fatal Exception: java.io.FileNotFoundException: Could not find file at path: /data/user/0/in.oku.brofirst/files/1497511679961.jpg
   at in.oku.brofirst.services.uploadservice.core.UploadFile.<init>(SourceFile:37)
   at awm.a(SourceFile:78)
   at awm.a(SourceFile:145)
   at awf.a(SourceFile:87)
   at awf.a(SourceFile:116)
   at in.oku.brofirst.services.uploadservice.util.NetworkChangeReceiver.onReceive(SourceFile:45)
   at android.app.ActivityThread.handleReceiver(ActivityThread.java:2732)
   at android.app.ActivityThread.access$1800(ActivityThread.java:153)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1428)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:148)
   at android.app.ActivityThread.main(ActivityThread.java:5438)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)

      

File transfer method

  public File transferFile(File file) {
    FileOutputStream fos = null;
    FileChannel inChannel = null;
    FileChannel outChannel = null;
    try {
        File transferredFileTo = new File(file.getName());// have the original name as the name in internal memory
        inChannel = new FileInputStream(file).getChannel();
        fos = context.openFileOutput(transferredFileTo.getName(), MODE_PRIVATE);
        outChannel = fos.getChannel();
        inChannel.transferTo(0, inChannel.size(), outChannel);
        return transferredFileTo;
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        Crashlytics.logException(e);
    } catch (IOException e) {
        e.printStackTrace();
        Crashlytics.logException(e);
    } finally {
        try {
            if (inChannel != null && fos != null) {
                inChannel.close();
                fos.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
            Crashlytics.logException(e);
        } finally {
            //ultimately delete the file from gallery
            deleteLatestFile();
            deleteFileFromTempFolder(file);
        }
    }
    return null;
}

      

Crashlytics

enter image description here

+3


source to share





All Articles