With the help of LAMW's examples I am trying to create an application that among other things will take a photo and store it in the last record of a sqlite table. The table structure is:
CREATE TABLE [EPISKEPSI4](
[IDEPISK3] INTEGER PRIMARY KEY AUTOINCREMENT,
[MERA] DATE DEFAULT CURRENT_DATE,
[FIGURE] BLOB,
[ID_REF] INTEGER);
While it saves other elements in the table, it saves the photo in the DCIM folder, it does not save the photo in the table.
What am I doing wrong;
procedure TFvisitland.Button16Click(Sender: TObject);
begin
if IsRuntimePermissionGranted('android.permission.CAMERA') and
IsRuntimePermissionGranted('android.permission.WRITE_EXTERNAL_STORAGE') then
begin
Camera1.Filename :='vis_'+inttostr(10)+'_'+FormatDateTime('ddmmyyyyMMssSSS',now())+'.jpg' ;
Camera1.RequestCode := 12345;
Camera1.TakePhoto;
end
else ShowMessage('Sorry... Some Runtime Permission NOT Granted ...');
end;
procedure TFvisitland.FvisitlandActivityResult(Sender: TObject;
requestCode: integer; resultCode: TAndroidResult; intentData: jObject);
var
photoPath: string;
photo_id:integer;
begin
if resultCode = RESULT_CANCELED then
begin
ShowMessage('Photo Canceled!')
end
else if resultCode = RESULT_OK then //ok...
begin
if requestCode = Camera1.RequestCode then
begin
photoPath:= Camera1.FullPathToBitmapFile ;
DbVisitLandPhoto.close;
DbVisitLandPhoto.OpenOrCreate('ApkAgros.db');
DbVisitLandPhoto.select('Select max(IDEPISK3) from Episkepsi4;') ; // Find Last record
photo_id:=DbVisitLandPhoto.Cursor.GetValueAsInteger(0) ;
DbVisitLandPhoto.close;
DbVisitLandPhoto.OpenOrCreate('ApkAgros.db');
DbVisitLandPhoto.UpdateImage('EPISKEPSI4','FIGURE','EPISK3',photopath,photo_id);
DbVisitLandPhoto.close;
end;
end
else
ShowMessage('Photo Fail!');
end;