不要从外部存储打开数据库

时间:2019-05-20 12:26:06

标签: android android-sqlite

我需要从文件(例如sdcard的示例)打开Sqlite数据库。 我得到了Uri:

          Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
          intent.setType("*/*");

接下来我尝试:

 sqLiteDatabase = SQLiteDatabase.openDatabase(uri.getPath(), null, 
 SQLiteDatabase.OPEN_READONLY);

并得到错误:

 E/SQLiteLog: (14) cannot open file at line 35803 of [605907e73a]
  (14) os_unix.c:35803: (2) 
 open(/document/raw:/storage/emulated/0/Download/jym.db) - 
 E/SQLiteDatabase: Failed to open database 
 '/document/raw:/storage/emulated/0/Download/jym.db'.
 android.database.sqlite.SQLiteCantOpenDatabaseException: unknown 
 error (code 14): Could not open database

0 个答案:

没有答案