我试图从一个类中创建一个数据库。该应用程序停止在Api 22+上运行,我在logcat中收到此错误:
Unable to create application com.android.tools.fd.runtime.BootstrapApplication: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
代码:
public class G extends Application {
public static SQLiteDatabase database;
public static final String DIR_SDCARD = Environment.getExternalStorageDirectory().getAbsolutePath();
public static final String DIR_DATABASE = DIR_SDCARD + "/DO_NOT_DELETE/";
@Override
public void onCreate() {
super.onCreate();
new File(DIR_DATABASE).mkdirs();
database = SQLiteDatabase.openOrCreateDatabase(DIR_DATABASE + "/database.sqlite", null);
}
}
在低于5的Android版本上运行它没有问题。我还在AndroidManifest.xml中添加了所需的权限。可能是什么问题?
答案 0 :(得分:1)