as you can see, this is my first question here, I hope that the question is specific enough for you. I am new to the android environment and could not find any answer because the error is rather specific.
I encountered a problem while implementing a ContentProvider Class for more than one Table. When accessing one table via the provider in my app via
ContentResolver cr = getApplication().getContentResolver();
Cursor c = cr.query(Uri.parse(URL_PRIVATE),null, null, null, null );
And the following setting: The accessed table has the structure of
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"rsaPrivateKey" BLOB NOT NULL,
"rsaPublicKey" BLOB NOT NULL,
"phoneNumber" TEXT NOT NULL,
and only one sample entry. Here is the problem, when I use
c.getString(0)
c.getBlob(1)
c.getBlob(2)
c.getString(3)
the output of c.getBlob(1) and c.getBlob(2) are switched, and I cannot explain that. I.e c.getBlob(1) returns the Public Key and c.getBlob(2) returns the Private Key. The method for the query in the ContentProvider class is as followed
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
// choose different database table
switch (uriMatcher.match(uri)){
case CONT:
qb.setTables(TABLE_NAME_CONTACTS);
break;
case CONT_ID:
qb.setTables(TABLE_NAME_CONTACTS);
break;
case OWN:
qb.setTables(TABLE_NAME_OWN);
break;
case OWN_ID:
qb.setTables(TABLE_NAME_OWN);
break;
}
Cursor c = qb.query(db, projection, selection, selectionArgs,
null, null, null);
c.setNotificationUri(getContext().getContentResolver(), uri);
return c;
}
I tried to get more information about the SQLiteQueryBuilder, but from my point of view, there is no reason, how this can happen, because the query method of the provider simply parses it into the db.query, and every parameter in this example is null. Maybe you can help me, I am sure, that the keys are correctly inserted in the table, this is not the source of the problem.
Aucun commentaire:
Enregistrer un commentaire