Here's my code which handles this use case. I never got the exact error that you saw (error code 100: unknown error). My code was tested against the android-16 version of the zumero libs, running on a Nexus 10.
public class MainActivity extends Activity {
private File tempDBFullPath;
private String dbName;
private String cacheDir;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Get the full path to the databases directory.
File databasesPath = this.getDatabasePath("blah").getParentFile();
if (!databasesPath.isDirectory()) {
//These lines make sure that the databases directory is created.
databasesPath.mkdirs();
}
//Append the time to make sure that we create a new,empty database
//and a new internal auth db each time we run this Activity.
this.dbName = "testdb" + new Date().getTime();
this.tempDBFullPath = new File(databasesPath, dbName);
this.cacheDir = this.getCacheDir().getAbsolutePath();
//Can't do network on the main thread.
AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
com.zumero.sqlite.SQLiteDatabase db = com.zumero.sqlite.SQLiteDatabase.openOrCreateDatabase(MainActivity.this.tempDBFullPath, null);
String userDB = MainActivity.this.dbName + "_users";
boolean bExec = false;
String serverAddress = "https://zinst12345.s.zumero.net";
String adminPassword = "PASSWORD";
Log.v("test", "======== creating internal auth ==========");
Cursor c = null;
if (bExec) {
//When I run this one, I get "com.zumero.sqlite.SQLiteException: unknown error: Queries cannot be performed using execSQL(), use query() instead."
//That behavior matches the gingerbread android database package.
db.execSQL("SELECT zumero_internal_auth_create('" + serverAddress +"', '" + userDB + "', zumero_internal_auth_scheme('zumero_users_admin'), 'admin', '" + adminPassword + "', NULL,NULL,'',zumero_named_constant('acl_who_anyone'),'',zumero_named_constant('acl_who_anyone') );)");
}
else {
//This one works.
c = db.rawQuery("SELECT zumero_internal_auth_create(?, ?, zumero_internal_auth_scheme(?), ?, ?, NULL,NULL,'',zumero_named_constant('acl_who_anyone'),'',zumero_named_constant('acl_who_anyone') );", new String[] {serverAddress, userDB, "zumero_users_admin", "admin", adminPassword });
//WATCH OUT! rawQuery doesn't actually execute until the call to moveToFirst.
c.moveToFirst();
}
Log.v("test", "======== adding user ==========");
if (bExec) {
//When I run this one, I get "com.zumero.sqlite.SQLiteException: unknown error: Queries cannot be performed using execSQL(), use query() instead."
db.execSQL("SELECT zumero_internal_auth_add_user('" + serverAddress + "', '" + userDB + "', zumero_internal_auth_scheme('zumero_users_admin'), 'admin', '" + adminPassword + "', 'newUsername', 'newPassword');");
}
else {
//This one works.
c = db.rawQuery("SELECT zumero_internal_auth_add_user(?, ?, zumero_internal_auth_scheme(?), ?, ?, ?, ?);", new String[] {serverAddress, userDB, "zumero_users_admin", "admin", adminPassword, "newUsername", "newPassword" } );
c.moveToFirst();
}
Log.v("test", "======== creating zumero acl table for this DB file. ==========");
c = db.rawQuery("SELECT zumero_define_acl_table('main');", null);
c.moveToFirst();
Log.v("test", "======== giving newUsername full permission to this DB file. ==========");
db.execSQL("INSERT INTO z_acl (scheme,who,tbl,op,result) VALUES (zumero_internal_auth_scheme('" + userDB + "'), zumero_named_constant('acl_who_specific_user') || 'newUsername', '', '*', zumero_named_constant('acl_result_allow'));");
Log.v("test", "======== executing admin sync so that the server has the new acl table ==========");
c = db.rawQuery("SELECT zumero_sync('main', ?, ?, zumero_internal_auth_scheme(?), ?, ?, ?);", new String[] {serverAddress, dbName, "zumero_users_admin", "admin", adminPassword, MainActivity.this.cacheDir } );
c.moveToFirst();
Log.v("test", "======== executing sync as the new user. ==========");
c = db.rawQuery("SELECT zumero_sync('main', ?, ?, zumero_internal_auth_scheme(?), ?, ?, ?);", new String[] {serverAddress, dbName, userDB, "newUsername", "newPassword", MainActivity.this.cacheDir } );
c.moveToFirst();
db.close();
return null;
}
};
task.execute((Void)null);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}