在本机描述的应用程序设置中存储收藏夹数组



我发现tns-core-modules/application-settings能够在设备上存储数据。我有一个应用程序,我想将用户的收藏夹存储到设备中。

假设我存储了一个最喜欢的歌曲列表,我可以使用setStringgetString,但我不确定如何通过编程来获得所有歌曲。有没有其他我缺少的选项或方法来实现这一点,其中可以使用songs作为密钥访问dict,并且可以加载所有songs

JSON.stringifysetString/JSON.parsegetString一起使用。

// Set favorite songs 
appSettings.setString("favorites", JSON.stringify(songs));
// Get favorite songs
const songs = JSON.parse(appSettings.getString("favorites", "{}"));

最新更新