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
Tushar Vengurlekar
7,6698 gold badges37 silver badges48 bronze badges
-
Does the database name need to be in quotes?James Goodwin– James Goodwin2013年02月06日 13:56:24 +00:00Commented Feb 6, 2013 at 13:56
-
the string refers to path of database. So it should not be.Tushar Vengurlekar– Tushar Vengurlekar2013年02月06日 14:00:03 +00:00Commented Feb 6, 2013 at 14:00
1 Answer 1
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
CL.
182k18 gold badges241 silver badges282 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
Phil
Does this actually work? I cannot reference the attached database. For example,
SELECT * FROM SomeName.tableThatExists fails with a no such table error.CL.
@Phil To ask a question, use the "Ask Question" button. But I guess you have this problem.
lang-sql