0

I'm pretty new using ORMLite with android, and I read in this question that the method onCreate() of the class OrmLiteSqliteOpenHelper is not called when the database already exists... but I'd like to confirm it by myself, does anyone know how to check if the database exists?

4
  • i haven't written a single line of android code in my whole life. here is my answer: an sqlite database is just a file. if the database file exists, the database exists. otherwise it exists not. Commented May 3, 2014 at 22:04
  • I understand your point, but I read that ORMLite creates the database in a local storage folder... and you can't access that folder without super user permissions, so... that way it's not as easy as it sounds. Commented May 3, 2014 at 22:09
  • hmm. if sqlite has readaccess there, your app should have too, no? sqlite is just an ordinary library. or are you communicating with it through some local RPC mechanism? Commented May 3, 2014 at 22:12
  • SQLite is a very light weight database which comes with Android OS. The database exists with 2 two default tables android_metadata & sqlite_sequence. Commented May 3, 2014 at 22:26

2 Answers 2

1

It looks like OrmLiteSqliteOpenHelper inherits the getWritableDatabase() method from SQLiteOpenHelper. If that method returns null, then the database does not exist.

Sign up to request clarification or add additional context in comments.

Comments

0

You can also create a database by using SQLiteDatabase for example

SQLiteDatabase = StackOverFlowDB;
//Creating database
    StackOverFlowDB = MainActivity.this.openOrCreateDatabase("StackOverFlow", MODE_PRIVATE, null);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.