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
JavaRanch » Java Forums » Mobile » Android
Bookmark "Check if SQLite DB is present" Watch "Check if SQLite DB is present" New topic
Author

Check if SQLite DB is present

Vishal Trivedi
Ranch Hand

Joined: Sep 05, 2011
Posts: 57
Hii


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


KARTHICK.C , SCJP6-93%
(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....
 
 
subject: Check if SQLite DB is present