Examples of projects for backing up Sqlite files and photos to Google Drive programmatically in Android

I am writing an application with instant messaging. Users will write text or share images in the IM function. The text data and the image file name are stored in the sqlite file, and the images are stored in the device .

Since my server will not save the data, the user will not receive a chat record when he switches to a new device . As for whatsapp, they allow users to regularly save chat recordings and images on Google Drive and return data from disk, as shown in the figure below.

enter image description here When I switch to my own Google drive, I would find that “Whatsapp” is connected to my Google drive, as shown below.

enter image description here I am new to the Google Drive API on Android, and I would like to backup my database and SQLite images in the same way as Whatsapp. I know that there are several issues related to backing up the sqlite database to Google Drive, but it seems that it contains only part of the codes, and this makes it difficult for beginners to understand.

Will there be any sample projects on github, questions about stackoverflow or tutorials that will let me know how to backup sqlite database and images programmatically on Android step by step

In addition, I am surprised to see that I’m just connected to my Google Drive , but no more than other applications, so I don’t know if a third-party developer will have the same access to Google. Manage and complete the backup in the same way as Whatsapp.

+10
android sqlite google-drive-sdk google-drive-android-api google-drive-api
source share
3 answers

Have you seen https://github.com/googledrive/android-demos ? I think you need to follow “Create a file in the application folder” to save your sqlite file in the user's hidden AppData folder. To get the return file, you can request the AppData folder (make sure you call requestSync () before the request to make sure the cache is updated).

+4
source share

This is certainly doable. You will need to learn how to programmatically upload files to Google Drive .

Will there be any sample projects on github, questions about stackoverflow or tutorials that will let me learn how to backup sqlite database and images programmatically in Android step by step?

There are several examples, for example:

To download images, please note that you will use a mimetype image , for example image / png for .png and image / jpeg for .jpg files. To load the SQL database to disk, here is a snippet from this example .

String mimeType = MimeTypeMap.getSingleton().getExtensionFromMimeType("db"); MetadataChangeSet changeSet = new MetadataChangeSet.Builder() .setTitle(GOOGLE_DRIVE_FILE_NAME) // Google Drive File name .setMimeType(mimeType) .setStarred(true).build(); // create a file on root folder Drive.DriveApi.getRootFolder(api) .createFile(api, changeSet, result.getDriveContents()) .setResultCallback(backupFileCallback); 
+3
source share

Really want to programmatically back up your SQLite file and photos on Google Drive in Android. And you want to transfer or use files from your Google Check this Out drive.

Follow this link: How to create or generate a direct link to download Google Drive using the link generator .

0
source share

All Articles