Create a Secure Backup System with Drive

So in this guide I’ll try to create a secured backup system just like WhatsApp. It backups user’s data to a hidden folder (AppDataFolder) in their own drive. Google offers this folder for apps to create files which will be hidden from user and can be viewed or downloaded only from the app which created it.

Firstly, you need a GDrive extension. I have published two and they are following:

  1. [PAID] GDrive: Just a Google Drive(App Data Folder) extension [$8 or INR 551]
  2. GDrive: Extended version of former GDrive extension [$15 or INR 1001]

The one which is priced $8 is solely dedicated to this purpose only. However, it does not mean that extended version can’t do this thing. In fact, extended version is for doing much more things and explore drive outside that hidden location.


I assume you have already created GCloud Project with Drive API enabled and added your app to it.

So having all the required files lets get started.

1. Import and Add Main + Deps extensions to the project and add them to the screen as well

2. Initialize the extension

If you are using extended version then you need to change SetScope property to AppDataScope which can be done in this way:

With other one, there is no need to change anything.
From here, blocks will be the same for both versions.

3. Get consent from User

Launch the auth flow and authentication as well as Drive permission will be asked inclusively.


You can always check if user has granted permission or not with this block

4. Upload Backup file

Now you have created a local backup which you want to store in the drive, so you do the following:

There is no need to store fileId but in case you want then you surely can.

5. Restore backup

User re-installed your app and now he/she want to restore the data which has been backed up recently. So you get the list of files.

After that, you do so work with the list to find which one was uploaded last time.
Let’s say you suffix milliseconds value of upload time or numbers like 1,2,3 etc. so you sort the list in ascending order , reverse the list and select first element.

Then you get file id corresponding to that file name.

Now you can download the backup file.

That’s it.
Now let’s quickly get a preview of how it looks.

With this, I hope this helps.
Thank you.

Notify of
Inline Feedbacks
View all comments