I want to backup and restore my sqlite db. For this i am using google drive api. I have used this this demo code. All works perfect. I can upload and download my db until i uninstall my app.
But then i notice a strange behavior. The scenario is as follow
Uninstall my application
Re-install it and try to download file from drive.
At this time i cant found any file from drive....search returns 0 always...i dont know why. All works perfect if i dont uninstall app and just clear data.
Here is my code for uploading....
public boolean createFile() {
DriveId dId = null;
String mimeType = MimeTypeMap.getSingleton().getExtensionFromMimeType("db");
if (mGoogleApiClient != null && mGoogleApiClient.isConnected())
try {
DriveFolder pFldr = Drive.DriveApi.getAppFolder(mGoogleApiClient);
if (pFldr != null) {
File file = context.getDatabasePath(db.getDatabaseName());
DriveContents cont = file2Cont(null, file);
MetadataChangeSet meta = new MetadataChangeSet.Builder().setTitle(Google_Drive_File).
setMimeType(mimeType).build();
DriveFolder.DriveFileResult r1 = pFldr.createFile(mGoogleApiClient, meta, cont).await();
DriveFile dFil = r1 != null && r1.getStatus().isSuccess() ? r1.getDriveFile() : null;
if (dFil != null) {
DriveResource.MetadataResult r2 = dFil.getMetadata(mGoogleApiClient).await();
if (r2 != null && r2.getStatus().isSuccess()) {
dId = r2.getMetadata().getDriveId();
}
}
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
return dId == null ? false : true;
}
Please help me....
well i have solved it....i was not getting file because i was using debug key in auth certificate. All works perfect as soon as i change my debug key with release.