Helo,
If I want save a double in the device, I can write:
B4X:
Sub Globals
Dim FileNUMBERS As String : FileNUMBERS = "Sets.txt"
Dim Number as Double
Dim MyNumber as Double
End Sub
Sub BtnEnreg_Click
Number = 50
Dim List1 As List
List1.Initialize
List1.Add(Number)
File.WriteList(File.DirInternal, FileNUMBERS,List1)
End Sub
And if I want to load and recover my number I can write
B4X:
Sub BtnLoad_Click
Dim List1 As List
If File.Exists(File.DirInternal,FileNUMBERS) Then
List1 = File.ReadList(File.DirInternal,FileSETTINGS)
MyNumber = List1.Get(0)
End Sub
What is the syntax to do the same thing with a picture? I want to save a picture taken with camera and load it later
Sub SaveBitmap (b As Bitmap, myDir As String, myFileName As String)
Dim out As OutputStream
out = File.OpenOutput(myDir, myFileName, False)
b.WriteToStream(out, 100, "JPEG")
out.Flush
out.Close
End Sub
Sub BtnSave_Click
SaveBitmap(lastPicture,File.DirInternal,"Foto.png")
End Sub
And I Load the saved picture with
B4X:
Sub BtnLoad_Click
Dim bg As Bitmap = LoadBitmapResize(File.DirInternal, "Foto.png", ImageView1.Width, ImageView1.Height, True)
ImageView1.SetBackgroundImage(bg).Gravity = Gravity.CENTER
End Sub
It seems that it does't find the path "java.io.FileNotFoundException: /storage/3064-3162/Foto.png (No such file or directory)"
1. No need to call out.Flush.
2. No need to change the filename case.
3. The code you posted is correct. The problem is somewhere else. Maybe you are trying to load the image before it was saved.