java.lang.IllegalArgumentException:未知的URL内容://com.example

时间:2017-03-21 16:24:57

标签: java android

我已经花了很多时间寻找解决这个问题的方法,但不幸的是我已经解决了这个问题!你能帮帮我吗?

android manifest:

<?xml version="1.0" encoding="utf-8"?>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <provider android:name="com.example.dias_rodrigo_esig.monEnfant.data.monEnfantProvider"
        android:authorities="com.example">
    </provider>
    <activity
        android:name=".ProfilActivity"
        android:theme="@style/CouleursProfil" />
    <activity
        android:name=".NourritureActivity"
        android:theme="@style/CouleursNourriture" />
    <activity
        android:name=".VaccinsActivity"
        android:theme="@style/CouleursVaccins" />
    <activity
        android:name=".TrouverHopitalMedecinActivity"
        android:theme="@style/CouleursHopital" />
    <activity
        android:name=".ContactsActivity"
        android:theme="@style/CouleursPediatre" />
    <activity
        android:name=".EvenementsActivity"
        android:theme="@style/CouleursEvenement" />
    <activity android:name=".EditeurProfilActivity"
        android:theme="@style/CouleursProfil"
        />
    <activity android:name=".EditeurVaccinsActivity"
        android:theme="@style/CouleursVaccins"
        />
    <activity android:name=".EditeurContactsActivity"
        android:theme="@style/CouleursPediatre"
        />
    <activity android:name=".EditeurEvenementActivity"
        android:theme="@style/CouleursEvenement"
        />
    <activity android:name=".EditeurNourritureActivity"
        android:theme="@style/CouleursNourriture"
        />
    <activity android:name=".EditeurHopitalActivity"
        android:theme="@style/CouleursHopital">

    </activity>
</application>

ContractClass:

私人MonEnfantContract()     {

}

public static final String CONTENT_AUTHORITY = "com.example.dias_rodrigo_esig.monEnfant/";

public static final Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY);

public static final String PATH_EVENEMENT="monEnfantProvider";


public static final class monEnfantEntry implements BaseColumns
{
    public static final Uri CONTENT_URI=Uri.withAppendedPath(BASE_CONTENT_URI, PATH_EVENEMENT);

    public static final String CONTENT_LIST_TYPE= ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_EVENEMENT;

    public static final String CONTENT_ITEM_TYPE=ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_EVENEMENT;


    /* Création de la table Enfant et ses attributs*/
    public static final String TABLE_NAME_Enfant = "Enfant";
    public static final String COL_1_ENFANT_ID= BaseColumns._ID;
    public static final String COL_2_ENFANT_NOM = "Nom";
    public static final String COL_3_ENFANT_PRENOM = "Prenom";
    public static final String COL_4_ENFANT_POIDS = "PoidsEnfant";
    public static final String COL_5_ENFANT_HAUTEUR = "HauteurEnfant";
    public static final String COL_6_ENFANT_DATE_NAISSANCE="DateNaissance";
    public static final String COL_7_ENFANT_VILLE_NAISSANCE = "VilleNaissance";


    /* Création de la table Vaccins et ses attributs*/
    public static final String TABLE_NAME_Vaccins = "Vaccins";
    public static final String COL_1_Vaccins_ID = BaseColumns._ID;
    public static final String COL_2_Vaccins_NOM = "VaccinsNom";
    public static final String COL_3_Vaccins_DATE = "VaccinsDate";


    /* Création de la table Nourriture et ses attributs*/
    public static final String TABLE_NAME_Nourriture = "Nourriture";
    public static final String COL_1_Nourriture_ID = BaseColumns._ID;
    public static final String COL_2_Nourriture_NOM = "NourritureNom";
    public static final String COL_3_Nourriture_TYPE = "NourritureType";
    public static final String COL_4_Nourriture_CATEGORIE_ = "NourritureCategorie";

    /* Création de la table CONTACT et ses attributs*/
    public static final String TABLE_NAME_Contacts = "Contacts";
    public static final String COL_1_Contacts_ID = BaseColumns._ID;
    public static final String COL_2_Contacts_NOM = "ContactNom";
    public static final String COL_3_Contacts_TELEPHONE = "ContactTelephone";


    /* Création de la table Hopital et ses attributs*/
    public static final String TABLE_NAME_Hopital = "Hopital";
    public static final String COL_1_Hopital_ID = BaseColumns._ID;
    public static final String COL_2_Hopital_NOM = "HopitalNom";
    public static final String COL_3_Hopital_ADRESSE = "HopitalAdresse";
    public static final String COL_4_Hopital_TELEPHONE = "HopitalTelephone";


    /* Création de la table Evenement et ses attributs*/
    public static final String TABLE_NAME_Evenement = "evenements";
    public static final String COL_1_Evenement_ID =BaseColumns._ID;
    public static final String COL_2_Evenement_NOM = "EvenementNom";
    public static final String COL_3_Evenement_MESSAGE = "EvenementDate";
    public static final String COL_4_Evenement_DATE = "EvenementMessage";




}

}

image for the activity

活动打开并显示表单以输入新事件,但是当我填写并单击保存时,应用程序将停止并显示此错误:

调试日志:

E/AndroidRuntime: FATAL EXCEPTION: main
              Process: com.example.dias_rodrigo_esig.mon_enfant, PID: 15621
              java.lang.IllegalArgumentException: Unknown URL content://com.example.dias_rodrigo_esig.monEnfant/monEnfantProvider
                  at android.content.ContentResolver.insert(ContentResolver.java:1272)
                  at com.example.dias_rodrigo_esig.monEnfant.EditeurEvenementActivity.saveEvenement(EditeurEvenementActivity.java:134)
                  at com.example.dias_rodrigo_esig.monEnfant.EditeurEvenementActivity.onOptionsItemSelected(EditeurEvenementActivity.java:196)
                  at android.app.Activity.onMenuItemSelected(Activity.java:3204)
                  at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:408)
                  at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:198)
                  at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:113)
                  at android.support.v7.app.AppCompatDelegateImplV9.onMenuItemSelected(AppCompatDelegateImplV9.java:675)
                  at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:822)
                  at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:156)
                  at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:969)
                  at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:959)
                  at android.support.v7.widget.ActionMenuView.invokeItem(ActionMenuView.java:623)
                  at android.support.v7.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:154)
                  at android.view.View.performClick(View.java:5637)
                  at android.view.View$PerformClick.run(View.java:22429)
                  at android.os.Handler.handleCallback(Handler.java:751)
                  at android.os.Handler.dispatchMessage(Handler.java:95)
                  at android.os.Looper.loop(Looper.java:154)
                  at android.app.ActivityThread.main(ActivityThread.java:6119)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

我已经尝试用我在这里发现的帖子解决问题,但它没有用。 提前谢谢。

1 个答案:

答案 0 :(得分:1)

 <provider android:name="com.example.dias_rodrigo_esig.monEnfant.data.monEnfantProvider"
    android:authorities="com.example">

此处,您的权限字符串为com.example

public static final String CONTENT_AUTHORITY = "com.example.dias_rodrigo_esig.monEnfant/";

此处,您的权限字符串为com.example.dias_rodrigo_esig.monEnfant/

首先,这些不匹配。其次,com.example.dias_rodrigo_esig.monEnfant/可能是无效的权限字符串,因为它不应该有/

修改您的代码,以便在两个地方使用相同的权限。