--> 好的,我在 SD 卡中有一个 Sq-lite 数据库。
(String DB_PATH = Environment.getExternalStorageDirectory().getPath().toString();)
--> 检查数据库是否存在
dbFile = new File(DB_PATH + DB_NAME );
if(dbFile.exists()== true)
{
//set text db exists
open_DB();
}
else
{
//set text db does not exist
return;
}
--> 在调试时我可以确认数据库文件的存在。但是打开
数据库时出现异常
SQLiteDatabase checkDB = null;
try
{
dbFile = new File(DB_PATH + DB_NAME);
myDataBase = SQLiteDatabase.openOrCreateDatabase(dbFile, null);
//myDataBase = SQLiteDatabase.openDatabase(DB_PATH + DB_NAME, null, 0);
//also tried this
//set text bd opened
}
catch(SQLiteException e)
{
//set text bd unable open
return;
}