How to download file from Google Drive and restore db from it How to download file from Google Drive and restore db from it sqlite sqlite

How to download file from Google Drive and restore db from it


You can pull down the GDAA CRUD wrapper from here. It uses the simplest form of GDAA calls, the 'await' flavor. As long as you wrap any of these calls to non-UI threads (Thread, AsyncTask) you should be OK.
If you decide to go this way (see how GDAA class communicates with MainActivity - connection, authorization), you basically need 3 methods:

  1. search for your file using it's title, mime, or whatever criteria you have, resulting in a valid DriveId. You may also use the DriveId you obtained from previous upload.
  2. read the file content into a byte[] buffer
  3. save your buffer into a DB file on your android device.

The demo shows uploading / downloading of JPEG images to/from the Drive (disregard the REST branch, it is there only for testing). You're dealing with a DB file, but in the end it still is a buffer/stream full of binary data that is uploaded/downloaded (with some metadata like title, mimetype,...).

Good Luck