同步Android db本地和MySQL的最佳方法

时间:2015-02-06 12:45:07

标签: android xml web-services synchronization

我有一个应该从Web服务器使用XML的Android应用程序。当要同步的数据很小时,我完成的同步工作完美,但是当数据较大时,应用程序失败并且不完成同步。当我说更大的时候我说要使用19 MB的XML并将其插入到Android本地数据库中。我该怎么做才能解决这个问题? 抱歉我的英文。

这里有一些代码:

String resposta = Util.executePost(context,"RelacionamentoCelularPontoDeVendaProduto/ListarRelacionamentos", pairs);
if(resposta.contains("<lista>")) {
        resposta = resposta.substring(resposta.indexOf("<lista>")+7, resposta.indexOf("</lista>"));
        String[] dados = resposta.split("<item xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"relacionamentoCelularPontoDeVendaProdutoVO\">");
        String pontoStr, produtoStr;
        ProdutoVO produto;
        for (String dado : dados) {
            if(dado.contains("<pontoDeVenda>") && dado.contains("</pontoDeVenda>") && dado.contains("<produto>") && dado.contains("</produto>")){
                item = new RelacionamentoPontoDeVendaProdutoVO();
                pontoStr = dado.substring(dado.indexOf("<pontoDeVenda>") + "<pontoDeVenda>".length() , dado.indexOf("</pontoDeVenda>"));
                item.setPontoDeVenda(new PontoDeVendaVO(Integer.parseInt(pontoStr.substring(pontoStr.indexOf("<id>") + "<id>".length() , pontoStr.indexOf("</id>")))));

                lista.add(item);
            }
        }
    }
    return lista;

这个名为lista的列表在第一次同步时有45000个寄存器插入到Android本地数据库中。 '

0 个答案:

没有答案
相关问题