德尔福XE5 Android开发"无法打开数据库文件" [英] Delphi XE5 Android Dev "unable to open database file"

查看:319
本文介绍了德尔福XE5 Android开发"无法打开数据库文件"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也跟着一步<一本教程一步href=\"http://docwiki.embarcadero.com/RADStudio/XE5/en/Mobile_Tutorial%3a_Using_SQLite_%28iOS_and_Android%29\"相对=nofollow>手机教程:使用SQLite(iOS和Android)的,但是当我在我的Andr​​oid设备上部署我的应用程序并尝试添加一个条目,我得到以下错误的无法打开数据库文件

I followed this tutorial step by step Mobile Tutorial: Using SQLite (iOS and Android) but when I deploy my application on my android device and attempt to add an entry, I get the following error "unable to open database file"

下面是我的code的一个片段:

Here is a snippet of my code:

procedure TForm1.rappadAfterConnect(Sender: TObject);
begin
      rappad.ExecuteDirect('CREATE TABLE IF NOT EXISTS notes(ID INTEGER PRIMARY KEY, title TEXT NOT NULL, content TEXT NOT NULL);');
end;

procedure TForm1.rappadBeforeDisconnect(Sender: TObject);
begin
  {$IF DEFINED(iOS) or DEFINED(ANDROID)}
  rappad.Params.Values['ColumnMetadataSupported'] := 'False';
  rappad.Params.Values['Database'] :=
      TPath.Combine(TPath.GetDocumentsPath, 'rappad.s3db');
  {$ENDIF}
end;

有谁知道这是为什么实际发生的事情?谢谢!

Does anyone know why is this actually happening? Thanks!

推荐答案

在code你有你的 rappadBeforeDisconnect 需要在 BeforeConnect 来代替。有没有在告诉你在哪里的之前,数据库所在的连接断开没有一点

The code you have in your rappadBeforeDisconnect needs to be in BeforeConnect instead. There's no point in telling the connection where the database is located before you disconnect.

procedure TForm1.rappadBeforeConnect(Sender: TObject);
begin
  {$IF DEFINED(iOS) or DEFINED(ANDROID)}
  rappad.Params.Values['ColumnMetadataSupported'] := 'False';
  rappad.Params.Values['Database'] :=
      TPath.Combine(TPath.GetDocumentsPath, 'rappad.s3db');
  {$ENDIF}
end;

这篇关于德尔福XE5 Android开发&QUOT;无法打开数据库文件&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆