0

I have an app with the SQlite DB inside and MySQL DB on the server.


SQLite:

Table 1: some columns

Table 2: some columns

MySQL:

The same tables and columns.


I want to ask you: Is it possible and is it the proper way for creating such functionality, like:

User starts the app and there is two buttons <=> activities (Activity 1 & Activity 2)

Activity 1: ListView with data from Table 1

Activity 2: ListView with data from Table 2

For example, user chooses Activity 1. The application proposes to user to update the data. If he/she agrees, the app makes connection with the server and updates SQlite DB Table 1 with data from MySQL DB Table 1.

The same is for Activity 2, but now, the data will be downloaded from Table 2.

Thanks in advance.

4

1 回答 1

1

您所描述的非常好,我建议创建一个内容提供程序来包装您的 sqlite 数据库。这样您就可以利用许多框架函数来获取数据。

您可能必须实现 CursorAdapter 才能在 listView 中填充数据。

查看此链接以了解有关内容提供者和 Sqlite 的更多信息 http://www.vogella.com/articles/AndroidSQLite/article.html

查看此链接以了解有关光标适配器的更多信息

http://blog.cluepusher.dk/2009/11/16/creating-a-custom-cursoradapter-for-android/

查看此 Google I/O 以了解您可以在应用中实现的架构

http://www.google.com/events/io/2010/sessions/developing-RESTful-android-apps.html

于 2012-08-09T20:41:33.080 回答