Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Check if SQLite DB is present

 
Vishal Trivedi
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 196
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Vishal Trivedi
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks karthick
i have figured it out

i have used


Thanks again....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic