我有数据存储类,我使用这个类来尝试GCM。我不明白数据的保存位置(注册ID),但我可以在重新启动IDE(Eclipse)之后重新执行此操作
谢谢朋友们
private static final DatastoreService datastore =
DatastoreServiceFactory.getDatastoreService();
private Datastore() {
throw new UnsupportedOperationException();
}
/**
* Registers a device.
*
* @param regId device's registration id.
*/
public static void register(String regId) {
logger.info("Registering " + regId);
Transaction txn = datastore.beginTransaction();
try {
Entity entity = findDeviceByRegId(regId);
if (entity != null) {
logger.fine(regId + " is already registered; ignoring.");
return;
}
entity = new Entity(DEVICE_TYPE);
entity.setProperty(DEVICE_REG_ID_PROPERTY, regId);
datastore.put(entity);
txn.commit();
} finally {
if (txn.isActive()) {
txn.rollback();
}
}
}
/**
* Gets all registered devices.
*/
public static List<String> getDevices() {
List<String> devices;
Transaction txn = datastore.beginTransaction();
try {
Query query = new Query(DEVICE_TYPE);
Iterable<Entity> entities =
datastore.prepare(query).asIterable(DEFAULT_FETCH_OPTIONS);
devices = new ArrayList<String>();
for (Entity entity : entities) {
String device = (String) entity.getProperty(DEVICE_REG_ID_PROPERTY);
devices.add(device);
}
txn.commit();
} finally {
if (txn.isActive()) {
txn.rollback();
}
}
return devices;
}
答案 0 :(得分:0)
当您在生产服务器中时,数据存储在GAE数据存储区中;当您处于本地开发环境(https://appengine.google.com/ - &gt;应用程序 - &gt;数据存储区索引)时,数据存储在本地文件中。 在任何情况下,您都可以从管理控制台查看应用程序中存储的数据。对于开发环境,您可以查看
localhost:8888 / _ah / admin(来自您的浏览器)