我正在开发一个应用程序和ContentProvider以提供一些内部文件(二进制文件)。当我将它部署在三星Galaxy S,SII或任何其他设备上时,它可以很好地工作,当我在Galaxy Nexus或Nexus S上尝试购买时,它无法正常工作!内容提供商不能在Nexus家庭设备上工作
场景:
我可以使用两个URI访问我的ContentProvider。根据这个URI,提供者创建一个DataCursor(扩展CrossProcessCursor)或ModelCursor(也扩展CrossProcessCursos)。事实是,在Nexus系列,我访问的第一个光标(DataCursor)检索标识,它完美的作品,但访问的第二个的时候,它总是试图
getBlob(时抛出“OutOfBoundsException” )
方法。
提供商
@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;
}
如果你需要一些代码或什么,只是要求它请!
非常感谢。
对于初学者:** ** 1有什么确切的SDK版本出现在你的Android设备? ** 2。**每个设备上的确切* SQLite *版本是什么('adb shell sqlite3 --version')** 3。**代码是否在模拟器中正常工作? ** 4。**什么是完整调用堆栈,当你得到* OutOfBoundsException *时? ** 5。* ModelCursor *如何实现? ** 6。**你的数据库模型是什么? ** 7。**你如何使用你的内容提供者(代码)? – vArDo 2012-08-09 10:55:53
1.从2.3.3到4.0(各种设备)2.重要吗?我可以检查它们,但ModelCursor不从SQLite获取数据,只是从内部文件存储中获取数据。 [要测试,谢谢]。 4. [链接](http://pastebin.com/NS7zBSGx)。来自“简明英汉词典”只需通过“getBlob”和其他需要的[link](http://pastebin.com/q4kMAEw3)。 6.不需要数据库。 7.'Cursor modelCursor = getContentResolver()。query(Uri.parse(“content://”+ PROVIDER_NAME +“/ model”),null,null,new String [] {modelId},null);' - 'modelCursor .getBlob(0);' – manelizzard 2012-08-10 07:54:36
您是否尝试将光标移至第一个条目? ('modelCursor.moveToFirst()') – SteveR 2012-08-10 16:21:57