0
public static final String TABLE_COMMENTS = "comments";
  public static final String COLUMN_ID = "_id";
  public static final String COLUMN_COMMENT = "comment";

// Database creation sql statement
  private static final String DATABASE_CREATE = "create table "
      + TABLE_COMMENTS + "(" + COLUMN_ID
      + " integer primary key autoincrement, " + COLUMN_COMMENT
      + " text not null);";

can any one pls explain what above line doing .Am new to android.Is TABLE_COMMENT a column in table that we are creating?Why we have used "("?

vaibvorld
  • 389
  • 2
  • 6
  • 20
  • This is more of a SQL question than an Android specific one. – TheZ Sep 28 '12 at 18:01
  • its a table's name and COLUMN_ID and COLUMN_COMMENT are columns.. – G_S Sep 28 '12 at 18:02
  • You should have a look into the SQLite documentation http://www.sqlite.org/lang_createtable.html – zapl Sep 28 '12 at 18:12
  • If you are new to Android-Sqlite ...try this: http://stackoverflow.com/questions/9109438/how-to-use-existing-database-with-android-app/9109728#9109728 Sample code: http://sdrv.ms/N857Wn – Yaqub Ahmad Sep 28 '12 at 18:25

3 Answers3

0

TABLE_COMMENTS is name of your table which resolves to comments!

private static final String DATABASE_CREATE = "create table "
      + TABLE_COMMENTS + "(" + COLUMN_ID
      + " integer primary key autoincrement, " + COLUMN_COMMENT
      + " text not null);";

The complete query would become

create table comments (
      id integer primary key autoincrement, 
      comment text not null
  );
Anshu
  • 7,783
  • 5
  • 31
  • 41
0

TABLE_COMMENTS: name of table.

COLUMN_ID: Name of a auto increment ID field.

COLUMN_COMMENT: comment, name of a textfield column in the table

Why you have used"("? Because that is the syntax

Araw
  • 2,410
  • 3
  • 29
  • 57
0

The TABLE_COMMENTS is a table named: comments.

The COLUMN_ID and COLUMN_COMENT are columns.

The "(" is to open the Table preferences, the code does: Create a table > (inside the brackets it creates the columns.)

baTimá
  • 554
  • 1
  • 10
  • 28