weixin_39757122
weixin_39757122
2021-01-11 09:44

How to use go-sqlite for android/iOS

I am creating a GO module which will be exported as library for Android/iOS apps (example: .aar for Android). I want to added database operation to this go module and using it in android and ios apps as both supports sqlite. I tried with examples provided. When i use "$go run [filename]" it creates db and runs without any issue. But when I add sqlite example code to my module and export it as '.aar' file (using gomobile bind) and include it in my android project and try to run. i get following error log

I/GoLog: "unable to open database file: no such file or directory": create table foo (id integer not null primary key, name text); delete from foo;

The issue was reported earlier ass well

https://github.com/golang/go/issues/18194#issue-193398369

but no proper solution posted and no information available. please let me know how to use go-sqlite in android devices

该提问来源于开源项目:mattn/go-sqlite3

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • weixin_39707851 weixin_39707851 4月前

    I think the intent was just to determine if the source of the error you are getting is actually SQLite itself, or just some file system issue, like the filepath being wrong, or you not having proper permissions.

    点赞 评论 复制链接分享
  • weixin_39712724 weixin_39712724 4月前

    What happens if you remove go-sqlite from the picture and simply do a os.Open() with the same file path that you pass to sql.Open() ?

    点赞 评论 复制链接分享
  • weixin_39757122 weixin_39757122 4月前

    -m I need sqlite for database operation. go-sqlite is working ok my PC (Desktop Application) but getting this error when i try the test program on mobile. I need go-sql working with gomobile

    点赞 评论 复制链接分享
  • weixin_39757122 weixin_39757122 4月前

    What happens if you remove go-sqlite from the picture and simply do a os.Open() with the same file path that you pass to sql.Open() ?

    -m Also "os.Open()" cannot do any DB operations which is why I need sql

    点赞 评论 复制链接分享