aspose file tools*
The moose likes Android and the fly likes Check if SQLite DB is present Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Check if SQLite DB is present" Watch "Check if SQLite DB is present" New topic

Check if SQLite DB is present

Vishal Trivedi
Ranch Hand

Joined: Sep 05, 2011
Posts: 57

I am developing an application that uses xml files from asset folder to populate database tables.
The code for the same is called from onCreate() method of my main activity.
However the problem is the database will be rewitten even if it is present causing useless processing

I wish to introduce a check where i can know if DB is present or not so that creating tables each time will be avoided.Is there a way to check this??

karthick chinnathambi
Ranch Hand

Joined: Jul 06, 2009
Posts: 196

i suppose that the problem is with you creating a database... Aren't you using SQliteOpenHelper ??

or else

if you wan't to actually check if a specific table is present or not just query the table for some fields (probably "_ID" field) . If the cursor is null the table doesn't exist

(Born to Win)
Vishal Trivedi
Ranch Hand

Joined: Sep 05, 2011
Posts: 57
thanks karthick
i have figured it out

i have used

Thanks again....
It is sorta covered in the JavaRanch Style Guide.
subject: Check if SQLite DB is present
Similar Threads
persistance question
Transfer data from Access DB to Oracle DB and Vice Versa in a java program
How to store Database tables in Cache
javax.servlet.ServletException:[Oracle][ODBC] [Ora]ORA-00942: table or view does not exist