mercredi 14 janvier 2015

Google drive How to restore database insert to my local database?

I want to restore my db ,and insert it to my local database


i try this code ,but local database is lost


please help me.



DriveContents content = result.getDriveContents();
try {
java.io.File dir = getApplicationContext().getDatabasePath(DATABASE_NAME);
BufferedInputStream in = new BufferedInputStream(content.getInputStream());
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(dir));


byte[] buffer = new byte[8 * 1024];
int n = 0;
while( ( n = in.read(buffer) ) > 0) {
out.write(buffer, 0, n);

}
out.flush();
in.close();
out.close();
content.discard(mGoogleApiClient);
showMessage("file done");

} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();

}

}

Aucun commentaire:

Enregistrer un commentaire