Android Question Taking a backup of an SQLLITE Database file to Google Drive - reg.

beelze69

Active Member
Licensed User
Hi,

I have an b4A app which stores data in an SQLLITE db. The database is stored in the mobile device.

I want to provide the following feature for the client

Assume: Google User-id would be picked from a 'settings file'.
:

When the client clicks on a 'BACKUP DATABASE TO GOOGLE DRIVE' button (say), the following should take place:

a) The application should detect if 'the end-user has already logged into Google'.
If not, it should display the 'STANDARD User-id and password dialog' of Google[the Google-Authentication dialog]
but with the 'user-id already pasted' from the 'Settings'

b) Upon typing the password and clicking on Login, the application should directly 'STORE/OVERWRITE' the existing SQLLITE.DB database in a 'pre-created folder under GOOGLE DRIVE of the client'.

c) if that folder is not created already in Google Drive, then the app should create that folder in Google Drive before saving the database file

d) if a) is already done .. meaning 'end-user has already logged into Google Drive' then it should directly do step c) [meaning app should detect that Google Authentication has already been done and directly access the Google Drive of the client and perform the activity in c) ]...

Requesting for help on:

1) Whether the below code is the right way to get to full path of my 'SQLLITE database file' in the MOBILE and copy to GoogleDrive ?
Presently thinking of doing the actual copy operation in this way ...(assuming I will get the PathInGoogleDrive which I do not know how to presently)
B4X:
Public RTP As RuntimePermissions
PUBLIC DBName="xyz.db"
Public PathInGoogleDrive as string 'the above string will hold the target path in the Google Drive..
SafeDirectory = RTP.GetSafeDirDefaultExternal("")

If File.Exists(SafeDirectory, DBName) = TRUE Then
Wait For (File.CopyAsync(SafeDirectory,DBName,PathInGoogleDrive, DBName)) Complete (Success As Boolean)

End If

Wwanted to know whether this will work with Google Drive Folder as the Target path...

2) How to do a),b), c) and d) above.

Thanks
 
Last edited:

beelze69

Active Member
Licensed User
Sorry Erel,

I will ask in the post one by one.

Firstly, thank you for referring me to the post 'Correct way to save files'..

My first doubt:

1) How can we detect if Google Authentication has already been performed by the mobile user in his/her device and if not invoke the 'Google Authentication services' which asks end-user for user-id and password ?

Thank you
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It doesn't matter whether the user has already authenticated or not. You simply use the SaveAs method and let the user select whichever local or remote storage service they like.

How can we detect if Google Authentication has already been performed by the mobile user
You can't detect it.
 
Upvote 0
Top