2
我在我的web空间上有一个数据库。现在我想下载这个数据库并将其复制到我的/数据库文件夹中。它复制了数据库的一些部分,但我无法访问它。随着“根资源管理器”,它说:“错误 - 当打开数据库时出现错误无法打开数据库文件”将数据库从服务器复制到Android
private final static String DB_NAME = "werweisswasquiz";
private final static String DB_PATH = "data/data/my-package-name/databases/";
try {
// Log.d(TAG, "downloading database");
URL url = new URL("http://unnediger.bplaced.net/Files/mydbfile");
URLConnection ucon = url.openConnection();
InputStream is = ucon.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(1024);
int current = 0;
while ((current = bis.read()) != -1) {
baf.append((byte) current);
}
/* Convert the Bytes read to a String. */
OutputStream myOutput = new FileOutputStream(DB_PATH+DB_NAME);
myOutput.write(baf.toByteArray());
myOutput.flush();
myOutput.close();
bis.close();
is.close();
} catch (Exception e) {
Log.e("DOWNLOAD", "downloadDatabase Error: ", e);
return false;
}
文件是否加密? – Rajesh
是某些列被加密。但不是整个数据库。 – androiddevjedi
数据库也无法从SQLite Manager打开。所以我猜想,您必须解密数据库或使用您用于加密内容的解密方法,以便在Android中访问它们。 – Rajesh