I'm developing an app with a ContentProvider to offer some inner files (binary files). When I deploy it on a Samsung Galaxy S, SII, or any other, it works perfectly, buy when I try it on a Galaxy Nexus or Nexus S, it doesn't work!
Scenario:
My ContentProvider can be accessed with two URIs. Depending on this URI, the provider creates a DataCursor (extending CrossProcessCursor) or ModelCursor (extending CrossProcessCursos also). The fact is that, in Nexus family, I access the first cursor (DataCursor) to retrieve an identifier, and it works perfectly, but when accessing the second one, it always throws "OutOfBoundsException" when trying
getBlob()
method.
Provider
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
Cursor cursor = null;
// If the third app requieres DATA (phrase id, phrase string and phrase name)
if(uri.toString().equalsIgnoreCase(ProviderConstants.DATA_URI.toString())) {
// Build the DataHelper and the customized cursor
DataHelper dataHelper = new DataHelper(getContext());
cursor = new DataCursor(dataHelper);
} else if(uri.toString().equalsIgnoreCase(ProviderConstants.MODEL_URI.toString())) {
// Let's take the model id from the selectionArgs...
if (selectionArgs != null && selectionArgs.length > 0) {
String modelId = selectionArgs[0];
// Get an instance to the persistent storage service...
File file = FileManager.getDirectory(getContext(), modelId);
FileSystemPersistentStorageService clientPersistentStorageService = new FileSystemPersistentStorageService(file);
cursor = new ModelCursor(clientPersistentStorageService);
} else {
Log.e("ContentProvider", "Query without model id on selectionArgs");
}
}
return cursor;
}
If you need some code or anything, just ask for it please!
Thanks a lot.
adb shell sqlite3 --version
) 3. Does the code work correctly in emulator? 4. What is the full call stack, when you get OutOfBoundsException? 5. How is ModelCursor implemented? 6. What is you database model? 7. How do you use your content provider (code)? – AconcaguagetBlob
and the other ones required link. 6. No database needed. 7.Cursor modelCursor = getContentResolver().query(Uri.parse("content://" + PROVIDER_NAME + "/model"), null, null, new String[] {modelId}, null);
-modelCursor.getBlob(0);
– FormicarymodelCursor.moveToFirst()
) – Neoteny