java - 如何在 android studio 应用程序中存储字符串 []?
问题描述
我只是在尝试这段代码,但它随后将我的手机变成了黑屏,并且在黑屏一段时间后它能够加载数据。
Gson gson = new Gson();
String json = gson.toJson(my_Arraylist<String>_here);
editor.putString("task list", json);
editor.apply();
谁能告诉我逃离那个黑屏的方法?
解决方案
您也可以在 runUiThread 方法中执行代码...
//This method will run your code in the background and update the UI when it is don
runUiThread(new Runnable(){
@Override
public void run(){
//Your code here
Gson gson = new Gson();
String json = gson.toJson(my_Arraylist<String>_here);
editor.putString("task list", json);
editor.apply();
}
});
推荐阅读
- node.js - 使用 node js 中的 Promise 递归目录列表
- powerbi - 来自不同表的 Power BI 日期差异没有关系
- ballerina - 如何使用 Xpath 和 Ballerina 在 XML 有效负载中搜索元素?
- sql-server - 具有相同表和列名的两个数据库,如何提取具有相似数据的一列而所有其他列显示差异?
- sql - 高效的 ANDing ORing 多个 id
- python - Django:在数据库中一次保存多个条目
- android - 以这种方式使用后退按钮是不好的做法吗?
- docker - Drupal - 如何查找 Drush 安装的模块名称?
- c++ - 在 EXE/DLL 之间传递数据
- android - 调用意图变量后应用程序崩溃