Android content provider provides unknown URL: // com

I try to create my own content provider and I get an error

Unknown url: //com.example.test.samplecontentprovider/yay

I have the following information in my manifest and content provider

<provider android:authorities="com.example.test.samplecontentprovider" android:multiprocess="true" android:name="com.example.test.SampleContentProvider"></provider> AUTHORITY = "com.example.test.samplecontentprovider" 

Where can I be wrong, please suggest.

A source package is also included here. http://www.fileserve.com/file/p4eNVgK

+4
source share
3 answers

here you go project fixin '

http://esilo.pl/Yea.zip

a few things ... Renault's answer ... but there are more errors:

 // there is no such constructor ... Android looking for simple SampleContentProvider() //public SampleContentProvider(Context context){ // mContext=context; //} @Override public boolean onCreate() { //so we move mContext initialization here mContext = getContext(); dbHelper = new DatabaseHelper(mContext); return true; } 

following:

 public static final class ContentProviderHelper { private ContentProviderHelper() {} //private static final String BASE_PATH = "yay"; we don't need it public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY); //you dont need it + "/" + BASE_PATH); public static final String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE + "/vnd." + COMPANY_NAME + "." + TABLE_NAME;//yay it stupid :P BASE_PATH; public static final String CONTENT_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE + "/vnd." + COMPANY_NAME + "." + TABLE_NAME;//yay it stupid :P BASE_PATH; public static final String ID = "_id"; public static final String TITLE = "title"; public static final String TEXT = "text"; } 

next in test.java:

  Uri uri = getContentResolver().insert( // we should replace SampleContentProvider.ContentProviderHelper.CONTENT_URI with CONTENT_URI + TABLE_NAME Uri.withAppendedPath(SampleContentProvider.ContentProviderHelper.CONTENT_URI, SampleContentProvider.TABLE_NAME), values); 
+4
source

From the provided sources, you made a mistake in determining your provider in AndroidManifest.xml: you need to determine the provider in the application tag , i.e.

 <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".test" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <provider android:authorities="com.example.test.samplecontentprovider" android:multiprocess="true" android:name="com.example.test.SampleContentProvider"></provider> </application> 
+10
source

I tried to find some solution about this and I rewrote the provider tag on my Android manifest as follows:

 <provider android:name=".database.FVProv" android:authorities="com.cevin.sukafilm4" android:exported="true" android:readPermission="com.cevin.sukafilm4.READ_DATABASE" android:writePermission="com.cevin.sukafilm4.WRITE_DATABASE" /> 

Hope this helps you

+1
source

All Articles