zoukankan      html  css  js  c++  java
  • Android实例-操作sqlite数据库之Grid显示图片(XE8+小米2)

    结果:

    1.数据库文件,记得打包到程序中(assetsinternal)。

    操作方法:

    1.新建firemonkey mobile application
    ①菜单->File->New->FireMonkey Mobile Application Delphi
    ②Blank Application
    ③设置分辨率。
    2.增加控件
    ①拖拽一个FDPhysSQLiteDriverLink1、FDGUIxWaitCursor1、FDConnection1、FDQuery1、Grid1。
    3.连接SQLite数据库
    ①首先用Navicat for SQLite做好一个测试库备用,表中需要有Image字段。
    ②双击FDConnection1->Definition->Driver ID->SQLite。
    ③下方的Database设置一下数据库的路径。
    ④FDQuery1->SQL->输入SQL语句如:“select * from MyTabel”。
    ⑤FDQuery1->Active->True。
    ⑥提示输入密码,不用管,直接点OK。
    4.绑定数据
    ①菜单->View->LiveBindings Designer。
    ②直接用手拖,把FDQuery1与Grid1联上。
    5.重要发布
    ①菜单Project->Deployment->Add File->选择中SQLite数据库。
    ②Remote Path->assetsinternal。
    6.手机程序中加增加的事件
    ①FDConnection1BeforeConnect事件增加增加代码“FDConnection1.Params.Values['Database']:=TPath.Combine
    (TPath.GetDocumentsPath,'test.db');”。
    ②Button1Click事件下可以写“ FDQuery1.Close; FDQuery1.Open;”。

    PS:有的人说不清楚在手机上,怎么用IMAGE加载图片。在此补充一下。

    procedure TForm1.Button2Click(Sender: TObject);
    var
    MS: TStream;
    begin
    with FDQuery1 do
    MS := CreateBlobStream(FieldbyName('myimage'), bmRead);
    Image1.Bitmap.LoadFromStream(MS);
    MS.Free;
    end;

  • 相关阅读:
    接口interface
    枚举类型
    编写Hello World ts程序
    TypeScript基本类型
    初始TypeScript
    session和cookie自动登录机制
    奇辉机车车号自动识别系统介绍
    AForge.NET 设置摄像头分辨率
    工作感概—活到老xio到老
    Scala学习二十二——定界延续
  • 原文地址:https://www.cnblogs.com/FKdelphi/p/4796115.html
Copyright © 2011-2022 走看看