源代码如下:

public static void createOrOpenDatabase() throws Exception
    {
        sld=SQLiteDatabase.openDatabase
        (
                "/data/data/me.Test2/me_Test_winxiangdb", //数据库所
                null,                                 //CursorFactory
                SQLiteDatabase.OPEN_READWRITE|SQLiteDatabase.CREATE_IF_NECESSARY //读写、若不存在则创建
        );
        String sql1="create table if not exists [bang] (id integer PRIMARY KEY AUTOINCREMENT,username text,score text,createtime timestamp,usetime text,pingyu text)";
        sld.execSQL(sql1); 
    }


错误信息如下:

sqlite returned: error code = 14, msg = cannot open file at source line 25502

之所以会这样是因为我的程序包名和数据库所在的路径不对。

在软件里我的包名称是:me.Test

而我的数九保存路径是:me.Test2/...android 为了安全,不让软件随便访问其他数据库所以会报错。

相关文章:

  • 2021-08-18
  • 2021-05-21
  • 2022-01-27
  • 2022-12-23
  • 2021-10-03
  • 2021-08-11
  • 2022-12-23
  • 2022-01-01
猜你喜欢
  • 2022-12-23
  • 2021-11-09
  • 2022-12-23
  • 2022-01-02
  • 2021-08-22
  • 2021-05-20
  • 2021-07-05
相关资源
相似解决方案