这是我的代码:
package com.alibdeir.database;
import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.parse.GetCallback;
import com.parse.Parse;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.SaveCallback;
import com.parse.ParseException;
public class MainActivity extends AppCompatActivity {
TextView output;
Button increase;
int currentInt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Parse.initialize(this, "QeaC0wiXsL9MyRbLaQ***********", "kDjoZVRu4OyWOGxPtPjh**************");
output = (TextView) findViewById(R.id.output);
increase = (Button) findViewById(R.id.increase);
ParseQuery query = new ParseQuery("int");
ParseObject o = query.get-("n6zA3CHxGx");
}
public void increase(View v) {
currentInt = Integer.parseInt(output.getText().toString());
output.setText(currentInt + 1 + "");
}
}
注意: ParseQuery query = new ParseQuery(“int”); ParseObject o = query.get(“n6zA3CHxGx”);
onhover of query.get(“n6zA3CHxGx”);我有标题中提到的错误。 我正在尝试更新解析云中的对象。 对象在云中。 请帮忙
答案 0 :(得分:0)
使用try { .. } catch
这样尝试处理异常的代码。
try {
Parse.initialize(this, "QeaC0wiXsL9MyRbLaQ***********", "kDjoZVRu4OyWOGxPtPjh**************");
output = (TextView) findViewById(R.id.output);
increase = (Button) findViewById(R.id.increase);
ParseQuery query = new ParseQuery("int");
ParseObject o = query.get-("n6zA3CHxGx");
} catch (com.parse.ParseException e1) {
e1.printStackTrace();
}
根据this解析论坛讨论 ACL设置默认为public read,owner-write。您可以更改这些以允许其他用户写入。
使用以下代码: -
ParseACL postACL = new ParseACL(ParseUser.getCurrentUser());
postACL.setPublicReadAccess(true);
postACL.setPublicWriteAccess(true);