Mobile backend starter cannot write user id in data store

I am using Google Mobile Backend Starter. I am trying to write a user id in a CloudEntity object with .setId, but when I try to write it to the data store using the CloudBackend.insert method. It only writes properties, but does not include my user id.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test);
    mTrackButton = (Button) findViewById(R.id.trackButton);
    mTrackButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
        sendData();

        }
    });
}
private void sendData(){

    CloudEntity ce = new CloudEntity("Try");
    ce.setId("Custom_ID");
    ce.put("Key1", "Value1");

    CloudCallbackHandler<CloudEntity> cch = new CloudCallbackHandler<CloudEntity>() {

        @Override
        public void onComplete(CloudEntity results) {
            Toast.makeText(TestActivity.this, "Sent to cloud", Toast.LENGTH_SHORT).show();

        }
        @Override
        public void onError(IOException e) {
            Toast.makeText(TestActivity.this, e.toString(), Toast.LENGTH_SHORT).show();
        }
    };

    getCloudBackend().insert(ce,cch);
}

datastore

Am I doing something wrong?

+4
source share
1 answer

Until I used a mobile backend starter, I used Datastore extensively.

The data warehouse automatically assigns unique keys to your entities when they are stored.

: https://cloud.google.com/appengine/docs/python/ndb/entities#entity_keys

, , .

, - , . .

.

0

All Articles