سؤال

I am following this tutorial: http://www.codeproject.com/KB/android/AndroidSQLite.aspx

I must be overthinking this SQLite stuff (in the past my domain server would automatically initialize databases I requested, and I could do queries when desired. never put one together from scratch)

I have some questions about their onCreate function. I never recall using a CREATE TRIGGER command in my SQL

I only need to create one table with 2 or 3 columns (if you count the primary key)

I should just be able to do db.execSQL("CREATE TABLE" + tableName +"("+colID+"INTEGER PRIMARY KEY,"+columnName+"TEXT)");

correct?

Do I need a "Trigger" and a "View" ?

هل كانت مفيدة؟

المحلول

If you just need a place to store some data - then Table is enough. But if your logic is more complicated then you'll need additional stuff.

Also note that some Triggers are not supported by SQLite: Info from here

نصائح أخرى

You not need to create TRIGGER. Unless it is required. Here is how I implemented in one of my project. Hope this help.

https://github.com/gopalB/FeedReader/blob/master/src/com/feedReader/provider/FeedDB.java

If you do not need a Trigger or a View, then you do not need to create them. It appears that the tutorial is just explaining some of the things you can do.

if SQLite TRIGGER and VIEW are similar to what they're used for in MySQL then no, they are not necessarily for what you're trying to accomplish.

VIEWs are useful when you have complex queries (like when using JOINs to join data from multiple tables).

TRIGGERSs are conditions that are run when you modify a table. (like using UPDATE, or INSERT)

As written, your create statement won't work because of a lack of whitespace. Try:

db.execSQL("CREATE TABLE " + tableName +" (" + colID + " INTEGER PRIMARY KEY, " + columnName + " TEXT)");
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top