0

What does execSQL (String sql) function which belongs to SQLiteDatabase actually do? i've read android documentation for it but not getting it..Please someone explain it in easy words.

Thanks in advance.

2 Answers 2

2

I know you've said you've read the Android documentation, but I'm going to link to it again as it's pretty well explained there. Taken from the Android documentation here

public void execSQL (String sql)

Execute a single SQL statement that is NOT a SELECT or any other SQL statement that returns data.

It has no means to return any data (such as the number of affected rows). Instead, you're encouraged to use insert(String, String, ContentValues), update(String, ContentValues, String, String[]), et al, when possible.

In other words, it's used to execute any queries that don't return data, such as updating a database's tuples or inserting new tuples to the database.

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

Comments

2

execSQL runs a single SQL query on the SQLiteDatabase and doesn't return any data. So if you wanted to insert something, or update something and didn't expect any information in return you would use this command.

Comments

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.