Android 无法保存数据,正在分析云
我刚刚开始使用Parse.com。试图保存三个简单变量Android 无法保存数据,正在分析云,android,parse-platform,Android,Parse Platform,我刚刚开始使用Parse.com。试图保存三个简单变量 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ParseObject testObject = new ParseObject("WorkTable"); testObject.put("f
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ParseObject testObject = new ParseObject("WorkTable");
testObject.put("foo", "bar");
testObject.put("foo1", "bar");
testObject.put("fo", "bar");
testObject.saveInBackground();
ParseAnalytics.trackAppOpenedInBackground(getIntent());
}
用于初始化解析和身份验证的类。是真实的应用程序ID和客户端密钥
public class ParseApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Parse.enableLocalDatastore(getApplicationContext());
Parse.initialize(this, "###", "###");
}
}
在舱单中:
<application
android:name="com.parse.starter.ParseApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.parse.APPLICATION_ID"
android:value="###" />
<meta-data
android:name="com.parse.CLIENT_KEY"
android:value="###" />
也许这意味着什么
凭据是正确的,检查了数十亿次。
已创建工作表,但它始终为空。
我做错了什么,请帮助。在你的应用程序中的某个地方,你需要记住设置你的应用程序id和Parse提供给你的密钥。我在onCreate方法中的一个应用程序对象中实现了这一点 Application.java:
public void onCreate() {
Parse.initialize(this, "Your Application Id", "Your Client Key");
}
然后只要在需要的地方创建新的parseobject
ParseObject gameScore = new ParseObject("GameScore");
gameScore.put("score", 1337);
gameScore.put("playerName", "Sean Plott");
gameScore.put("cheatMode", false);
gameScore.pinInBackground();
注意:不要忘了将应用程序名称指定为manifest'应用程序标记,如下所示:
<application
android:name=".Application"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
查看这些数据是否保存,让我知道发生了什么,并给出日志我都做了。在解析时,我可以在数据浏览器中看到此空表,但它是空的。请尝试从清单中删除元标记,并在解析数据库中定义所需的列。此答案没有帮助。显然他已经初始化了他的钥匙。此外,使用pinInBackground用于本地数据存储。saveInBackground是正确的。他在我之前的回答之后编辑了他的回答,他没有提到上述细节。我仍然说交叉验证应用程序id和客户端密钥。如果您有下面提到的配置,一切似乎都正常
<application
android:name=".Application"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
public class ParseApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
ParseCrashReporting.enable(this);
Parse.enableLocalDatastore(this);
Parse.initialize(this,"key", "key");
ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();
defaultACL.setPublicReadAccess(true);
ParseACL.setDefaultACL(defaultACL, true);
ParseObject a = new ParseObject("a");
a.put("shoe");
a.saveInBackground();
}
}