简体   繁体   English

Android:两种sqlite方法有什么区别

[英]Android: What is the difference between the two sqlite approaches

I look at a tutorial here: http://www.chupamobile.com/tutorial-android/android-beginner-tutorial-part-66-creating-sqlite-databases-340 我在这里看一个教程: http : //www.chupamobile.com/tutorial-android/android-beginner-tutorial-part-66-creating-sqlite-databases-340

and then I see this tutorial here: http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/ 然后在这里看到该教程: http : //www.androidhive.info/2011/11/android-sqlite-database-tutorial/

The first one does not create a class for the table while the second one does. 第一个不为表创建类,而第二个则为表创建类。 What are the advantages of creating and using that table class and CRUD class? 创建和使用该表类和CRUD类的优点是什么?

I need to create an app that will use a fixed structure local database. 我需要创建一个使用固定结构的本地数据库的应用程序。 3 tables interconnected and mainly display cursors in listviews. 3个表相互连接,并且主要在列表视图中显示光标。 I will load cursors into ListViews directly onClick of other listview items. 我将直接在其他listview项的onClick上将游标加载到ListViews中。 (Categories, Subcategories, FinalItems) (类别,子类别,FinalItem)

Later I will implement an activity for updating the contents of the database from a remote MySQL server. 稍后,我将实现一个活动,用于从远程MySQL服务器更新数据库的内容。 But this information is just to help you get the big picture. 但是,此信息仅是帮助您全面了解。

So for now I just want to know what road to take? 所以现在我只想知道走什么路? Is it necessary to build classes for my tables and for the CRUD operations? 是否有必要为我的表和CRUD操作构建类? Or is it enough to use the first tutorial? 还是使用第一个教程就足够了?

Thank you 谢谢

It is not "necessary" to create classes for your tables. 不必为您的表创建类。

The reasons for creating such classes is to manage complexity. 创建此类的原因是为了管理复杂性。 Your application sounds very simple, so such classes are likely unnecessary. 您的应用程序听起来很简单,因此此类不必要。

Large projects, become increasingly difficult to organize. 大型项目变得越来越难以组织。 At some point, it makes sense to move all of the code that talks to the database into either a single "Data Access Layer" class, or multiple classes (often one per table, but some tables just don't warrant a class). 在某个时候,将与数据库对话的所有代码移动到单个“数据访问层”类或多个类(每个表通常一个,但有些表只是不保证一个类)是有意义的。

My current project has to deal with a database containing just over 250 tables, as well as data coming in from web services. 我当前的项目必须处理一个仅包含250多个表的数据库,以及来自Web服务的数据。 Finding every line of code that talks to table X would be nearly impossible if I didn't have them all grouped neatly into a single class. 如果我没有将所有与表X整齐地组合在一起的代码,几乎不可能找到与表X对话的每一行代码。

It basically comes down to organization. 它基本上取决于组织。 The more complexity you are facing, the more organized you have to be. 您面临的复杂性越高,就必须越有条理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 这两种类初始化方法有什么区别? - What's the difference between these two approaches to class initialization? Android应用程序开发中Mysql和SQLite数据库之间有什么区别? - What's the difference between Mysql and SQLite database in android app development? mySQLi(myPhpAdmin)和SQLite(对于Android数据库)有什么区别? - What is the difference between mySQLi (myPhpAdmin) and SQLite (for Android database)? Android String.compareTo()和sqlite3_stricmp()有什么区别? - What the difference between Android String.compareTo() and sqlite3_stricmp()? Android - String 和 Sqlite 数据库上的数据有什么区别? - Android - What is the difference between data on String and on Sqlite database? Android的abc.db和abc.sqlite有什么区别? - What is the difference between the abc.db and abc.sqlite for android? SQLite 和 SQL 有什么区别 - What is difference between SQLite and SQL Android Animation Lags(两种方法之间有什么区别) - Android Animation Lags (what's the difference between two methods) 两种方法之间更新Android App Widget有什么区别? - What the difference to update Android App Widget between two approach? Android,获取当前线程ID的两种方法有什么区别? - Android, what is the difference between two ways of getting current thread Id?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM