Android Question [SOLVED]How to save image using CameraEx

Zvi

Member
Licensed User
I used the CameraEx example and it works perfectly, except that it doesn't save the image to my phone (Redmi Note4).
The relevant sub in the example is given as:
Sub Camera1_PictureTaken (Data() As Byte)
Dim filename As String = "1.jpg"
Dim dir As String = File.DirInternal
camEx.SavePictureToFile(Data, dir, filename)
camEx.StartPreview 'restart preview
ToastMessageShow("Picture saved." & CRLF & "File size: " & File.Size(dir, filename), True)
End Sub

The image directory on my android is: "\SanDisk SD card\DCIM\Camera\"
and the book "B4A Rapid Android App..." states "the image will be stored in the folder /mnt/sdcard/DCIM/Camera.

How should I modify the sub "PictureTaken" to save the image?
 

MarkusR

Well-Known Member
Licensed User
Longtime User
DirInternal sounds not like a camera folder
use
B4X:
Log(dir)
at my android 5.x device its /data/data/com.rauch.test/files
its contains the app package name
 
Last edited:
Upvote 0

Zvi

Member
Licensed User
Really appreciate it... this is the only way I can learn by struggling through. Thanks for the rope to pull myself up!!
 
Upvote 0

Zvi

Member
Licensed User
I tried to implement the code example.
I called the file "1.jpg" and the directory "\DCIM\Camera".
But when I take a picture the app shuts down.
Debugging and log errors show the problem at line 126 of CameraExClass:
Dim out As OutputStream = File.OpenOutput(Dir, FileName, False)

Error: java.io.FileNotFoundException: \DCIM\Camera/1.jpg: open failed: ENOENT (No such file or directory)

Dir is "\DCIM\Camera" and FileName is 1.jpg so I don't understand why it tries to open "\DCIM\Camera/1.jpg" instead of "\DCIM\Camera\1.jpg"

Any help would be greatly appreciated.
 

Attachments

  • Camera_Example.zip
    13.3 KB · Views: 299
Upvote 0

Zvi

Member
Licensed User
I have also tried modifying Dir to "/DCIM/Camera" but still get:
Error: java.io.FileNotFoundException: /DCIM/Camera/1.jpg: open failed: ENOENT (No such file or directory)
 
Upvote 0

Zvi

Member
Licensed User
When I connect my phone to my laptop the external directory (SD card) of my phone shows directory DCIM which contains the Camera directory.
 

Attachments

  • Screenshot - 30-Nov-18 , 13_52_18.png
    Screenshot - 30-Nov-18 , 13_52_18.png
    131.4 KB · Views: 212
Upvote 0
Top