将Sqlite数据库上载到远程服务器

时间:2011-10-03 10:04:37

标签: android

我正在使用我的设备收集数据,然后将其保存在本地sqlite数据库中。我现在尝试通过单击按钮将此数据库上载到远程服务器。 我已经能够上传整个数据库,但问题是无法查看内容,因为它们是使用UTF-8加密的(如果没有错)。当我打开上传的文件时,加密的文本以SQLite格式3开头,但其他输入的数据被加密。

以下是我实现上传的代码示例,如何将此文件解密回普通文本/字符?

    public void doUpload(String filepath, String filename) {
    HttpClient httpClient = new DefaultHttpClient();
    try {

httpClient.getParams().setParameter("http.socket.timeout",new Integer(90000));
        post = new HttpPost(new URI("http://10.0.2.2:8080/Force/sync"));
        File file = new File(filepath);
        FileEntity entity;
        if (filepath.substring(filepath.length() - 2, filepath.length()).equalsIgnoreCase("db" || filepath.substring(filepath.length() - 3, filepath.length()).equalsIgnoreCase("log")) {
            entity = new FileEntity(file, "text/plain; charset=\"SQLite format 3\"");
            entity.setChunked(true);                
        } else {
            entity = new FileEntity(file, "binary/octet-stream");
            entity.setChunked(true);                
        }
        post.setEntity(entity);
        post.addHeader(filepath, filename);

        HttpResponse response = httpClient.execute(post);
        if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {

        } else {
            // Here every thing is fine.
        }
        HttpEntity resEntity = response.getEntity();
        if (resEntity == null) {
        }
    } catch (Exception ex) {

        ex.printStackTrace();
    } finally {
        httpClient.getConnectionManager().shutdown();
    }
}

点击上传按钮调用此代码,url调用处理上传文件的servlet(sync)。

我会感激任何asist。 问候。

0 个答案:

没有答案
相关问题