我已经成功地将 dropbox 与我的应用程序集成,可以上传和下载文件,但是当我上传 sqlite 数据库文件然后下载后,该文件不包含任何数据。
这是我上传的代码:
public void upload() {
FileInputStream inputStream = null;
try {
File file = new File(Environment.getExternalStorageDirectory()
.toString() + "/tripmileagedatabase");
inputStream = new FileInputStream(file);
Entry newEntry = mDBApi.putFile("/tripmileagedatabase", inputStream,
file.length(), null, null);
Log.i("DbExampleLog", "The uploaded file's rev is: " + newEntry.rev);
} catch (DropboxUnlinkedException e) {
// User has unlinked, ask them to link again here.
Log.e("DbExampleLog", "User has unlinked.");
} catch (DropboxException e) {
Log.e("DbExampleLog", "Something went wrong while uploading.");
} catch (FileNotFoundException e) {
Log.e("DbExampleLog", "File not found.");
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
}
}
}
}
我的下载方法是:
public void download() {
FileOutputStream outputStream = null;
try {
File file = new File(Environment.getExternalStorageDirectory()
.toString() + "/tripmileagedatabase");
outputStream = new FileOutputStream(file);
DropboxFileInfo info = mDBApi.getFile("/tripmileagedatabase", null,
outputStream, null);
Log.i("DbExampleLog", "The file's rev is: "
+ info.getMetadata().rev);
// /path/to/new/file.txt now has stuff in it.
} catch (DropboxException e) {
Log.e("DbExampleLog", "Something went wrong while downloading.");
} catch (FileNotFoundException e) {
Log.e("DbExampleLog", "File not found.");
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
}
}
}
}
但是当我在我的应用程序中使用这个数据库时,它在那个数据库中没有显示任何数据,我现在该怎么办?