Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
titleExample code
Context context = this;
ContentResolver cr = context.getContentResolver();
Uri uri = Uri.parse("content://eu.mysync.android.dm.provider/user");
String[] projection = {"accountId", "deviceId", "orgCode", "serverUrl", "lastConnection"};
Cursor cursor = cr.query(uri, projection, null, null, null);
String msg;
if (cursor != null) {
   if (cursor.moveToFirst()) {
      String accountId = cursor.getString(0);
      String deviceId = cursor.getString(1);
      String orgCode = cursor.getString(2);
      String serverUrl = cursor.getString(3);
      long lastConnection = cursor.getLong(4);
      msg = "mySync is provisioned. accountId: " + accountId + " deviceId: " + deviceId + " orgCode: " + orgCode + " server: " + serverUrl + " lastConnection: " + lastConnection;
   } else {
      msg = "mySync is not provisioned (no user information provided)";
   }
   cursor.close();
} else {
   msg = "mySync is not installed or, mySync version does not support URI, or URI is wrong.";
}
Toast.makeText(context, msg, Toast.LENGTH_LONG).show();

...