pepsin
V2EX  ›  问与答

SQLite 如何变相存储数组呢?

  •  
  •   pepsin · Aug 28, 2011 via Android · 11056 views
    This topic created in 5550 days ago, the information mentioned may be changed or developed.
    遇上了这个问题,查到的答案都是建第二个表,不是太理解,求高人讲解
    6 replies  •  1970-01-01 08:00:00 +08:00
    icyflash
    icyflash
    Aug 28, 2011
    1
    看数组结构及自己的需求,可以考虑序列化成字符串
    Livid
    Livid
    MOD
    PRO
    Aug 28, 2011
    2
    取决于数组是什么类型。

    如果元素固定且数量就几十个左右的话,用列也是一种解决办法。
    pepsin
    pepsin
    OP
    Aug 28, 2011 via Android
    3
    @Livid 元素数量不定,存储的是字符串。

    考虑转换成字符串,用某种标识符隔开使用时再用正则取出来,但感觉很麻烦的样子。特别是取出的字符串还要考虑利用 android 的 intent 读取
    ssword
    ssword
    Aug 28, 2011
    4
    一对多关系。
    ayanamist
    ayanamist
    Aug 28, 2011
    5
    看了这个帖子中的疑问,我终于明白MongoDB提倡的schemeless的意义了
    popoer
    popoer
    Aug 28, 2011
    6
    转换成json格式存储吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   664 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 21:39 · PVG 05:39 · LAX 13:39 · JFK 16:39
    ♥ Do have faith in what you're doing.