HarmonyOS 首选项超长string存储失败?

首选项超长string存储失败,错误日志:

Convert2NativeValue: string  must be less than the limit length.
 SetAction: throw error: code = 401 , message = Parameter error. The type of value mast be ValueType.

我看首选项描述中有提到,如果存入值是string,长度不能超过 16*1024*1024字节

但我存入的string字符串只有 19942 呀

阅读 637
1 个回答

value值过长,首选项Value的最大长度限制为8192个字节。可考虑使用kv数据库或者rdb进行储存