问题描述
我正在为 Firestore 安装 Algolia extension。安装程序工作得很好,它在添加删除和更新时更新索引。但现在我想用现有数据回填它。
设置指南中提供了以下步骤,但我不知道如何运行该脚本。我试过直接将它粘贴到 node shell 和 powershell 中,将其添加到 js 或 ps1 文件并运行它,但我不知道这是什么类型的脚本。
我如何运行这个脚本? (我旁边有一个服务帐号json)
解决方法
这太棒了...
它在直接粘贴到 bash 中时起作用,在行终止符之后的每个换行符上都有空格。或者作为来自命令行的 // In preference fragment
private Preference bgPref;
@Override
public void onActivityResult(
int requestCode,int resultCode,@Nullable Intent data) {
super.onActivityResult(requestCode,resultCode,data);
if (resultCode == RESULT_OK && data != null) {
Uri imageUri = data.getData();
final String path = getFilePath(requireContext(),imageUri);
if (path != null) {
bgPref.setText(path); // how to set a string value for a Preference?
Drawable d = Drawable.createFromPath(path);
if (containerView != null) {
containerView.setBackground(d);
}
}
} else {
Toast.makeText(requireContext(),"You haven't picked Image",Toast.LENGTH_LONG).show();
}
}
// In Main activity
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
String bgPath = sharedPrefs.getString("bgPath","");
Drawable d = Drawable.createFromPath(bgPath);
if (!bgPath.isEmpty()) findViewById(R.id.nav_host_fragment).setBackground(d);
//...
文件。
.sh