第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

ContentProvider訪問數(shù)據(jù)出錯(cuò)

ContentProvider訪問數(shù)據(jù)出錯(cuò)

qq_我很丑絕緣體_0 2016-08-06 08:50:16
public?class?Myprovider?extends?ContentProvider?{ //定義一個(gè)UriMatcher器 private?static?final?UriMatcher?Myurimatcher=new?UriMatcher(UriMatcher.NO_MATCH); private?static?final?int?QUERYSECUSS?=?0; private?MyopenHelper?myopenHelper; static{ //定義靜態(tài)代碼塊用來添加匹配規(guī)則 /*authority:和在清單文件中自定義的必須一致 ? Myurimatcher.addURI("com.lianxi.myprovider",?"query",?QUERYSECUSS); } @Override public?boolean?onCreate()?{ myopenHelper?=?new?MyopenHelper(getContext()); return?false; } public?Cursor?query(Uri?uri,?String[]?projection,?String?selection, String[]?selectionArgs,?String?sortOrder)?{ int?code=Myurimatcher.match(uri); if?(code==QUERYSECUSS)?{//判斷調(diào)用者傳過來的uri和自己定義是否匹配 //若匹配成功把query方法實(shí)現(xiàn) SQLiteDatabase?sDatabase=myopenHelper.getReadableDatabase(); ????Cursor?cursor=sDatabase.query("info",?projection,?selection,?selectionArgs,?null,?null,?sortOrder); ????return?cursor; }else{ throw?new?IllegalArgumentException("路徑不匹配,請(qǐng)檢查路徑是否正確"); } }這是自己定義的內(nèi)容提供者!Mainactivity代碼如下:public?class?MainActivity?extends?Activity?{ ????@Override ????protected?void?onCreate(Bundle?savedInstanceState)?{ ????????super.onCreate(savedInstanceState); ????????setContentView(R.layout.activity_main); ??????? ????????Uri?uri=Uri.parse("content://com.lianxi.myprovider/query"); ??????Cursor?cursor?=getContentResolver().query(uri,?null,??null,??null,??null); ??????if?(cursor!=null?&&?cursor.getCount()>0)?{ while?(cursor.moveToNext())?{ String?name=cursor.getString(1); String?moneny=cursor.getString(2); System.out.println("內(nèi)容解析者查詢結(jié)果:name"+name+"--------moneny"+moneny); } }運(yùn)行工程報(bào)出如下日志:08-05?20:39:50.901:?E/AndroidRuntime(828):?java.lang.RuntimeException:?Unable?to?start?activity?ComponentInfo{com.lianxi.contenreciver/com.lianxi.contenreciver.MainActivity}:?java.lang.SecurityException:?Permission?Denial:?opening?provider?com.lianxi.createdatebase.Myprovider?from?ProcessRecord{41985148?828:com.lianxi.contenreciver/u0a10047}?(pid=828,?uid=10047)?that?is?not?exported?from?uid?10046求大神指教這是怎么回事。。!
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 1272 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)