开发者

SQL Server database and Android

I am connecting to a SQL Server database with the Android device. Yes I know not very advisable but everything works fine except ... well it's slo开发者_如何学运维w.

Here is what I do:

  • open conection
  • download table by table the data I need from the server database (with a connector I found online)
  • insert table by table into sqlite

I only select what I need; there are about 12 tables and some have like 300 items

Then I send some data to the server database (the select from 2 tables)

How could I make the thing work faster without using web services? (if possible)

If I do use web services will it be faster?

Thanks a lot in advance

PS: I know there are the risks about accessing the DB that way they are not relevant in this case.


Do you really need to replicate the same schema on Android? Try to narrow it down to only the essential data, and maybe create a new 'light' schema for the Android app. Do not use select *, only get the columns you need. Even with this, the first sync will probably be relatively slow. After you sync once, you can only get the newest items, so it should go faster.

If you want to use a webservice, you will have to rethink your model: instead of syncing tables with rows, you will work with entities (customers, orders, etc.). If you transfer the same amount of data, a webservice won't be faster, it can even be slower. The benefits of a webservice are that you don't have to know the exact schema on the server, so you don't need to change your app if it is changed (as long as it has all the data you need, of course); and that thinking in terms of a service will make you only use the data you need, making the whole interaction faster. And, it works over the Web, of course, so it will work with proxies, NAT, and what not.


After the initial sync, you could code your android app to retain the data in sqllite and only download the differences/changes on the next connection.

Depending on how changeable your data is on the server, this method could reduce you sync time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜