Android Question [Solved] java.io.FileNotFoundException: No content provider: Problem

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All,

Back with another problem.

I have an App that takes a Screen Shot and the user saves to SD Card. This bit working well.
The code below is my attempt to select and view these Screen Shots. The code is basically a rip-off of Erel's Text Editor to save/load to/from external memory.


B4X:
Sub BtnFiles_click
   
    If File.Exists(File.Dirinternal&"/ABT/", "") = False Then File.MakeDir(File.Dirinternal&"/ABT/", "")
    If File.Exists(File.Dirinternal&"/ABT/", "TempImage") = False Then File.Delete(File.Dirinternal&"/ABT/", "TempImage")
    LoadIMG            'Takes user to file handler screen, user selects image to import
End Sub

Private Sub LoadIMG
    Wait For (FileHandler1.LoadPNG) Complete (Result As LoadResult)
    HandleLoadResult(Result)
End Sub

Private Sub HandleLoadResult(Result As LoadResult)
    If Result.Success Then
        Private in As InputStream
        Private Out As OutputStream
        Private byte1() As Byte
        Private DirSource1 As String
        Private TempPNG As Bitmap
        Private LblH As Int = lblBTSLongLat.Height * 1.5
        
        Filename1 = Result.RealName
        DirSource1 = Result.Dir
        
'*******Gets file selected by FileHandler and stores it in DirInternal
        If Filename1.EndsWith(".png") Then

            byte1 = File.ReadBytes(DirSource1, Filename1)     '************ This line causes the error.

            in.InitializeFromBytesArray(byte1, 0, byte1.Length)
            TempPNG.Initialize2(in)
            
            Out = File.OpenOutput(File.Dirinternal&"/ABT/", "TempImage", False)
            TempPNG.WriteToStream(Out, 100, "PNG")
            Out.Close           
'***************Image is now in internal memory folder as "TempImage"
            
            
            
'************ Now display image
            ImgScreen.Top = LblH
            ImgScreen.SetBackgroundImage(LoadBitmap(File.Dirinternal&"/ABT/", "TempImage"))
            
            lblTitle2.Height = LblH
            lblTitle2.Gravity = Gravity.CENTER_HORIZONTAL
            lblTitle2.Text = Filename1
            ListBack2.Height = LblH
            ListBack2.Width = ListBack.Width
            ListBack2.BringToFront
            ListBack2.Visible = True
            ListBackFlag = True
            
        Else
            toast.Show("Not a Valid file.")
        End If
    Else
        toast.Show("No file loaded")
    End If   
End Sub

I have added added the following Sub LoadPNG into FileHanlder Class to handle PNG files.

B4X:
Public Sub LoadPNG As ResumableSub
    Dim cc As ContentChooser
    cc.Initialize("cc")
    cc.Show("image/*", "Choose image")
    Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
    Dim res As LoadResult = CreateLoadResult(Success, Dir, FileName)
    If res.Success Then ExtractInformationFromURI(res.FileName, res)
    Return res
End Sub

When I try to Load Here.PNG file I get this error:
java.io.FileNotFoundException: No content provider: Here_.png


Regards Roger
 

Roger Daley

Well-Known Member
Licensed User
Longtime User
Erel

Full error message:

Logger connected to: samsung SM-A705YN
--------- beginning of main
--------- beginning of system
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
No wakelock.
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
** Activity (main) Resume **
main_handleloadresult (java line: 6464)
java.io.FileNotFoundException: No content provider: Here_.png
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1972)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1801)
at android.content.ContentResolver.openInputStream(ContentResolver.java:1478)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:212)
at anywheresoftware.b4a.objects.streams.File.ReadBytes(File.java:427)
at horsetrailer.B4A.AntennaBearingTool.main._handleloadresult(main.java:6464)
at horsetrailer.B4A.AntennaBearingTool.main$ResumableSub_LoadIMG.resume(main.java:7384)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:267)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:207)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1770)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8506)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1139)
java.io.FileNotFoundException: No content provider: Here_.png
** Activity (main) Pause, UserClosed = false **
No wakelock.
** Activity (main) Resume **

Regards Roger
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Erel,

Logger connected to: samsung SM-A705YN
--------- beginning of system
--------- beginning of main
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
No wakelock.
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
** Activity (main) Resume **
[Dir=ContentDir, FileName=content://com.android.externalstorage.documents/document/6434-6130%3AFunctions1%2FHere_.png, IsInitialized=true

, MimeType=image/png, Modified=1629600378000, RealName=Here_.png
, Size=607453, Success=true]

main_handleloadresult (java line: 6466)
java.io.FileNotFoundException: No content provider: Here_.png
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1972)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1801)
at android.content.ContentResolver.openInputStream(ContentResolver.java:1478)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:212)
at anywheresoftware.b4a.objects.streams.File.ReadBytes(File.java:427)
at horsetrailer.B4A.AntennaBearingTool.main._handleloadresult(main.java:6466)
at horsetrailer.B4A.AntennaBearingTool.main$ResumableSub_LoadIMG.resume(main.java:7388)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:267)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:207)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1770)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8506)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1139)
java.io.FileNotFoundException: No content provider: Here_.png

Logs from Log(Result)


Roger
 
Last edited:
Upvote 0
Top