1

I am a beginner. I learn to SQLite. I don't understand function db.execSQL(DATABASE_CREATE);

private static final String DATABASE_CREATE = "create table users (_id integer primary key autoincrement, "  + "name text not null);"; 

So function db.execSQL(). How do it word? Please help me. Thank,

1
  • your question is unclear Commented Mar 8, 2012 at 21:02

2 Answers 2

8

From the Android SDK documentation for SQLiteDatabase:

execSQL(String sql): Execute a single SQL statement that is NOT a SELECT or any other SQL statement that returns data.

In your example, to create the table, you would call db.execSQL(DATABASE_CREATE) which would execute your table create statement on your application's SQLite database.

Sign up to request clarification or add additional context in comments.

Comments

0

this is the actual database where your data is stored. When you created your database with SQLiteOpenHelper class, it sets everything in motion to create your database but holds off until you are ready to use that database. And the way SQLiteOpenHelper knows that you are ready to use your database is when you access that database either with getReadableDatabase() or getWritableDatabase() for read and write operations respectively.

1 Comment

This didn't answer the question at all

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.