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;

  • 相关阅读:
    制作yaffs2文件系统
    nandwrite 参数
    linux并发控制之信号量
    mke2fs 制作ext2文件系统image
    stat文件状态信息结构体
    mount命令详解
    fiddler——http——cookie
    fiddler——http——请求方法、状态码
    http的cookie
    fiddler——http——header首部(请求首部和响应首部)——个人文档整理
  • 原文地址:https://www.cnblogs.com/FKdelphi/p/4796115.html
Copyright © 2011-2022 走看看