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.