简体   繁体   中英

How to check if a Sqlite database exists in android?

我在将ORMLite与android结合使用时还很陌生,并且在这个问题中我读到,当数据库已经存在时,不会调用类OrmLiteSqliteOpenHelper onCreate()方法。但是我想OrmLiteSqliteOpenHelper确认一下,有人吗?知道如何检查数据库是否存在?

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

You can also create a database by using SQLiteDatabase for example

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM