Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个预建的数据库,我使用 SQLiteMan 来填充包含短篇小说或文章的数据库,所以我有一个这样的表结构:
表:文本 id - 整数自增 标题 - 文本 内容 - blob
内容字段包含我从文本编辑器编辑的文本文件中的段落文本或字符串。
如何从数据库中以文本形式检索内容?
您可以像这样获取您的 blob 数据。
byte[] byteArray = cursor.getBlob(columnIndex);
鉴于您已询问“作为文本”,我将通过以下方式澄清先前的答案:
new String(cursor.getBlob(1), "utf-8");
当然,如果您使用了不同的字符集,那么您可以指定它而不是 utf-8。