0

I am getting following exception while attaching a sqlite database in another sqlite database in Android Application

android.database.sqlite.SQLiteException: near "/": syntax error: , while compiling: ATTACH DATABASE /data/data/PACKAGE_NAME/databases/database AS MASTER

Any suggestions what can cause this error.

Thanks,

asked Feb 6, 2013 at 13:50
2
  • Does the database name need to be in quotes? Commented Feb 6, 2013 at 13:56
  • the string refers to path of database. So it should not be. Commented Feb 6, 2013 at 14:00

1 Answer 1

2

The database name is an expression, so it must be quoted:

ATTACH DATABASE '/data/data/PACKAGE_NAME/databases/database' AS SomeName

And I doubt that the name of your package is actually PACKAGE_NAME, or that your database file is actually named database.

answered Feb 6, 2013 at 14:51
Sign up to request clarification or add additional context in comments.

2 Comments

Does this actually work? I cannot reference the attached database. For example, SELECT * FROM SomeName.tableThatExists fails with a no such table error.
@Phil To ask a question, use the "Ask Question" button. But I guess you have this problem.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.