大型sqlite数据库需要很长时间才能在Android Delphi XE7中加载

时间:2016-07-17 00:20:35

标签: sqlite delphi load

我使用Delphi XE7 TSQLConnection连接到大型SQLite数据库并将其部署在android上,它可以工作,但是当我在android上启动我的应用程序时需要很长时间才能加载,如何缩短加载时间

数据库有3个字段编号,文本,文本包含大约28,000条记录

这是我的代码和屏幕

unit Unit3;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, Data.DbxSqlite,
  Data.FMTBcd, Fmx.Bind.Grid, System.Rtti, System.Bindings.Outputs,
  Fmx.Bind.Editors, Data.Bind.EngExt, Fmx.Bind.DBEngExt, Data.Bind.Controls,
  FMX.Layouts, Fmx.Bind.Navigator, Data.Bind.Components, FMX.Memo, FMX.Grid,
  Data.Bind.Grid, Data.Bind.DBScope, Data.DB, Data.SqlExpr, Datasnap.DBClient,
  Datasnap.Provider, System.IOUtils, FMX.ListView.Types, FMX.ListView,
  FMX.MultiView;

type
  TForm3 = class(TForm)
    XxxConnection: TSQLConnection;
    TabledictTable: TSQLDataSet;
    TabledictTableIDCount: TWideMemoField;
    TabledictTableEnglish: TWideMemoField;
    TabledictTableRes: TWideMemoField;
    DataSetProvider1: TDataSetProvider;
    ClientDataSet1: TClientDataSet;
    DataSource1: TDataSource;
    BindSourceDB1: TBindSourceDB;
    BindingsList1: TBindingsList;
    MultiView1: TMultiView;
    ListView1: TListView;
    LinkListControlToField1: TLinkListControlToField;
    MemoRes: TMemo;
    LinkControlToFieldRes2: TLinkControlToField;
    procedure XxxConnectionBeforeConnect(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;

implementation

{$R *.fmx}
{$R *.LgXhdpiTb.fmx ANDROID}

procedure TForm3.FormShow(Sender: TObject);
begin
     xxxConnection.Open;
end;


procedure TForm3.XxxConnectionBeforeConnect(Sender: TObject);
begin
  {$IF DEFINED(IOS) or DEFINED(ANDROID)}
  xxxConnection.Params.Values['Database'] :=
        TPath.Combine(TPath.GetSharedDocumentsPath,'external/dictlao1.sdb.db')  { External }
  {$ENDIF}


end;

end.

screen shot of Delphi form screen shot of database connection

0 个答案:

没有答案