Recent

Author Topic: backup android database  (Read 1521 times)

kristof.project

  • New Member
  • *
  • Posts: 26
backup android database
« on: April 27, 2021, 12:05:02 am »
hello,

i found this code for copy my database but it not copy. database is present. the return code is "0"
is dirDownloads need "permission"

Code: Pascal  [Select][+][-]
  1.  
  2. test:=self.copyfile(Self.GetEnvironmentDirectoryPath(dirDatabase)+'/myData.db',
  3.  Self.GetEnvironmentDirectoryPath(dirDownloads)+'/recover.db');
  4.  showmessage('status copy:'+booltostr(test));
  5.  

thank
Lubuntu 22.04

shyub

  • Full Member
  • ***
  • Posts: 124
Re: backup android database
« Reply #1 on: April 27, 2021, 05:52:22 am »
If you are using Android 6 or higher, you need to get permission to access the file system. Take a look at the "AppOpenFileDialogDemo1" example. Include in your program the procedures "procedure TAndroidModule1.AndroidModule1JNIPrompt (Sender: TObject); procedure TAndroidModule1.AndroidModule1RequestPermissionResult (...".

kristof.project

  • New Member
  • *
  • Posts: 26
Re: backup android database
« Reply #2 on: April 27, 2021, 01:35:48 pm »
i'm using android 6 higher (target sdk29)

so i use this in my Jform similar acces camera but no ask for granted
Code: Pascal  [Select][+][-]
  1. procedure TFsignaler.FsignalerJNIPrompt(Sender: TObject);
  2. begin
  3.   Self.RequestRuntimePermission('android.permission.WRITE_EXTERNAL_STORAGE', 5001);
  4. end;
  5.  
  6. procedure TFsignaler.FsignalerRequestPermissionResult(Sender: TObject;
  7.   requestCode: integer; manifestPermission: string;
  8.   grantResult: TManifestPermissionResult);
  9. begin
  10.     if requestcode=5001 then
  11.       if grantResult = PERMISSION_GRANTED  then ShowMessage('autorisation carte sd ')
  12.         else ShowMessage('carte sd non autoriser');
  13. end;  
  14.  
  15.  

but if i understand WRITE_EXTERNAL_STORAGE will be out
I not found a issu, at same for assets directory
Lubuntu 22.04

Mongkey

  • Sr. Member
  • ****
  • Posts: 430
Re: backup android database
« Reply #3 on: April 28, 2021, 02:20:58 am »
maybe you can try like this:

permission granted
copy your db.

1. make sure permission is granted (to make sure just read apps info, does it granted or not)
2. re check your db file
3. copy your db on dextination folder

rsu333

  • Full Member
  • ***
  • Posts: 110
Re: backup android database
« Reply #4 on: April 28, 2021, 08:53:41 am »
I have experience that jtextfilemanager can copy DBF files  to SD .
So you can try it.

kristof.project

  • New Member
  • *
  • Posts: 26
Re: backup android database
« Reply #5 on: April 28, 2021, 09:56:23 am »
maybe you can try like this:

permission granted
copy your db.

1. make sure permission is granted (to make sure just read apps info, does it granted or not)
2. re check your db file
3. copy your db on dextination folder

can you share an example?
thank

Lubuntu 22.04

Mongkey

  • Sr. Member
  • ****
  • Posts: 430
Re: backup android database
« Reply #6 on: April 28, 2021, 10:04:08 am »
U should read more sample n doing more practices, good apps consuming good effort too, mr. JM, mr. Adiv n contributors do a lot work providing samples n very easy to follow ,  :D. Key -> permissions, n availibility your file to be backed up.
« Last Edit: April 28, 2021, 10:06:03 am by Mongkey »

kristof.project

  • New Member
  • *
  • Posts: 26
Re: backup android database
« Reply #7 on: April 28, 2021, 01:18:35 pm »
U should read more sample n doing more practices, good apps consuming good effort too, mr. JM, mr. Adiv n contributors do a lot work providing samples n very easy to follow ,  :D. Key -> permissions, n availibility your file to be backed up.

if ask for an example working, i have already searching example with my friend google, and try many time different example.

si if i can found issu, i looking with a distant sql server
Lubuntu 22.04

Mongkey

  • Sr. Member
  • ****
  • Posts: 430
Re: backup android database
« Reply #8 on: April 28, 2021, 02:25:14 pm »
Google not talking a lot about LAMW, samples provided are the best friend.

rsu333

  • Full Member
  • ***
  • Posts: 110
Re: backup android database
« Reply #9 on: April 28, 2021, 04:50:32 pm »
For examples LAZARUS-LAMW>menu>tools>example project is best.
For easy to understand Laz4andoid 2.0.0 is better than advance

 

TinyPortal © 2005-2018