Hi everybody I write this after i read all the topic about to read and write files on Android and AppInventor above all the very interesting and useful Some basics on Android storage system wrote by @Anke but after this I still I have my problem with files evidently I don't understand how to correct use.
I explain what I am trying to do. I am developing an extension to manage image file.
With the app I take a picture,
I retrieve the path where there is the file,
I send the path to the extension, at this point I have the java.io.FileNotFoundException
Here the blocks:
I take the picture and with Canvas.SaveAs I save the image
In a TextBox I write the path
I check if the path is correct with the Image1.Picture (works!)
I call the extension
the exception is here:
appendLog("File Position: "+ OBJECT_LOCATION);
File file = new File(OBJECT_LOCATION);
FileInputStream fileInputStream = new FileInputStream(file);
appendLog is a function to create a Log file to check what happens
here the log file:
File Position: file:///storage/emulated/0/CB.jpg
java.io.FileNotFoundException: file:/storage/emulated/0/CB.jpg: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:496)
at java.io.FileInputStream.(FileInputStream.java:159)
at FileStack.FileStack.sFTS(FileStack.java:108)
at FileStack.FileStack.uploadToFileStack(FileStack.java:73)
at java.lang.reflect.Method.invoke(Native Method)
at gnu.expr.PrimProcedure.apply(PrimProcedure.java:285)
at gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
at gnu.mapping.CallContext.runUntilValue(CallContext.java:298)
at gnu.mapping.MethodProc.applyN(MethodProc.java:113)
at gnu.kawa.reflect.Invoke.applyN(Invoke.java:193)
at gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:139)
at gnu.kawa.functions.Apply.applyN(Apply.java:70)
at gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)
at com.google.youngandroid.runtime.callComponentMethod(runtime4183767458063774083.scm:1061)
at java.lang.reflect.Method.invoke(Native Method)
at gnu.expr.PrimProcedure.apply(PrimProcedure.java:285)
at gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
at gnu.mapping.CallContext.runUntilValue(CallContext.java:298)
at gnu.mapping.MethodProc.applyN(MethodProc.java:113)
at gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:139)
at gnu.kawa.functions.Apply.applyN(Apply.java:70)
at gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)
at edu.mit.appinventor.aicompanion3.Screen1.dispatchEvent(Screen1.yail:10130)
at com.google.appinventor.components.runtime.EventDispatcher.delegateDispatchEvent(EventDispatcher.java:222)
at com.google.appinventor.components.runtime.EventDispatcher.dispatchEvent(EventDispatcher.java:199)
at com.google.appinventor.components.runtime.Button.Click(Button.java:50)
at com.google.appinventor.components.runtime.Button.click(Button.java:42)
at com.google.appinventor.components.runtime.ButtonBase.onClick(ButtonBase.java:780)
at android.view.View.performClick(View.java:7192)
at android.view.View.performClickInternal(View.java:7166)
at android.view.View.access$3500(View.java:824)
at android.view.View$PerformClick.run(View.java:27592)
at android.os.Handler.handleCallback(Handler.java:888)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:8178)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Linux.open(Native Method)
at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8046)
at libcore.io.IoBridge.open(IoBridge.java:482)
... 38 more
The path is correct, but for unknown reason (for me) the file is not found.
I don't understand why in the exception message there aren't two slash.
Well I hope I wrote everything and I hope You can help me, because I have a great headache.
Thank You
Best Regards
Marco