Click here to Skip to main content
14,579,188 members
   

Android

 
QuestionFile and App sharing app Pin
AdityaSha9hrs 32mins ago
MemberAdityaSha9hrs 32mins ago 
AnswerRe: File and App sharing app Pin
Richard MacCutchan3hrs 43mins ago
mveRichard MacCutchan3hrs 43mins ago 
QuestionMessage Closed Pin
29-Jun-20 21:49
MemberTrancis29-Jun-20 21:49 
Questionjava.lang.IllegalArgumentException: Unknown URI: content Pin
Ирина Костић23-Jun-20 13:56
MemberИрина Костић23-Jun-20 13:56 
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.projekat/com.example.projekat.EmailsActivity}: java.lang.IllegalArgumentException: Unknown URI: content://com.example.projekat/emails.db
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2805)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2883)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1613)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6523)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:445)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857)
     Caused by: java.lang.IllegalArgumentException: Unknown URI: content://com.example.projekat/emails.db
        at com.example.projekat.database.ContactsDBContentProvider.insert(ContactsDBContentProvider.java:79)
        at android.content.ContentProvider$Transport.insert(ContentProvider.java:265)
        at android.content.ContentResolver.insert(ContentResolver.java:1539)
        at com.example.projekat.tools.EmailsUtil.InitDB(EmailsUtil.java:23)
        at com.example.projekat.EmailsActivity.onCreate(EmailsActivity.java:73)
        at android.app.Activity.performCreate(Activity.java:7109)
        at android.app.Activity.performCreate(Activity.java:7100)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2758)


AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.projekat">

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <service android:name=".sync.SyncSerivce" />

        <receiver android:name=".sync.SyncReciever" />

        <activity android:name=".MainActivity"></activity>
        <activity
            android:name=".SplashActivity"
            android:label="Splash">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".LogInActivity"
            android:label="Login activity" />
        <activity
            android:name=".ContactActivity"
            android:label="Contact"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
        <activity
            android:name=".CreateContactActivity"
            android:label="Create contact"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
        <activity
            android:name=".ContactsActivity"
            android:label="Contacts"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
        <activity
            android:name=".ProfileActivity"
            android:label="Profile"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
        <activity
            android:name=".SettingsActivity"
            android:label="Settings"
            android:parentActivityName=".MainActivity"></activity>
        <activity
            android:name=".FolderActivity"
            android:label="Folder"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
        <activity
            android:name=".FoldersActivity"
            android:label="Folders"
            android:parentActivityName=".EmailsActivity" />
        <activity
            android:name=".EmailActivity"
            android:label="Email"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
        <activity
            android:name=".EmailsActivity"
            android:label="Emails"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
        <activity
            android:name=".CreateFolderActivity"
            android:label="Create folder"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
        <activity
            android:name=".CreateEmailActivity"
            android:label="Create Email"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
        <provider
            android:authorities="com.example.projekat"
            android:name="com.example.projekat.database.ContactsDBContentProvider"
            android:exported ="false"/>
        <provider
            android:authorities="com.example.projekat"
            android:name="com.example.projekat.database.EmailsDBContentProvider"
            android:exported ="false"/>

    </application>

</manifest>







public class EmailsDBContentProvider extends ContentProvider {


    private EmailsSQLiteHelper database;

    private static final int EMAILS = 11;
    private static final int EMAILS_ID = 21;

    private static final String AUTHORITY = "com.example.projekat";



    private static final String EMAILS_PATH = "emails.db";

    public static final Uri CONTENT_URI_EMAILS = Uri.parse("content://" + AUTHORITY + "/" + EMAILS_PATH);

    private static final UriMatcher sURIMatcher = new UriMatcher(UriMatcher.NO_MATCH);

    static {
        sURIMatcher.addURI(AUTHORITY, EMAILS_PATH, EMAILS);
        sURIMatcher.addURI(AUTHORITY, EMAILS_PATH + "/#", EMAILS_ID);
    }

    @Override
    public boolean onCreate() {
        database = new EmailsSQLiteHelper(getContext());
        return true;
    }

    @Nullable
    @Override
    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {

        SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();


        int uriType = sURIMatcher.match(uri);
        switch (uriType) {
            case EMAILS_ID:

                queryBuilder.appendWhere(EmailsSQLiteHelper.COLUMN_ID + "="
                        + uri.getLastPathSegment());

            case EMAILS:
                // Set the table
                queryBuilder.setTables(EmailsSQLiteHelper.TABLE_EMAILS);
                break;
            default:
                throw new IllegalArgumentException("Unknown URI: " + uri);
        }

        SQLiteDatabase db = database.getWritableDatabase();
        Cursor cursor = queryBuilder.query(db, projection, selection,
                selectionArgs, null, null, sortOrder);

        cursor.setNotificationUri(getContext().getContentResolver(), uri);

        return cursor;
    }

    @Nullable
    @Override
    public String getType(Uri uri) {
        return null;
    }

    @Nullable
    @Override
    public Uri insert(Uri uri, ContentValues values) {
        Uri retVal = null;
        int uriType = sURIMatcher.match(uri);
        SQLiteDatabase sqlDB = database.getWritableDatabase();
        long id = 0;
        switch (uriType) {
            case EMAILS:
                id = sqlDB.insert(EmailsSQLiteHelper.TABLE_EMAILS, null, values);
                retVal = Uri.parse(EMAILS_PATH + "/" + id);
                break;
            default:
                throw new IllegalArgumentException("Unknown URI: " + uri);
        }
        getContext().getContentResolver().notifyChange(uri, null);
        return retVal;
    }

    @Override
    public int delete(Uri uri, String selection, String[] selectionArgs) {
        int uriType = sURIMatcher.match(uri);
        SQLiteDatabase sqlDB = database.getWritableDatabase();
        long id = 0;
        int rowsDeleted = 0;
        switch (uriType) {
            case EMAILS:
                rowsDeleted = sqlDB.delete(EmailsSQLiteHelper.TABLE_EMAILS,
                        selection,
                        selectionArgs);
                break;
            case EMAILS_ID:
                String idEmails = uri.getLastPathSegment();
                if (TextUtils.isEmpty(selection)) {
                    rowsDeleted = sqlDB.delete(EmailsSQLiteHelper.TABLE_EMAILS,
                            EmailsSQLiteHelper.COLUMN_ID + "=" + idEmails,
                            null);
                } else {
                    rowsDeleted = sqlDB.delete(EmailsSQLiteHelper.TABLE_EMAILS, EmailsSQLiteHelper.COLUMN_ID + "=" + idEmails
                            + " and "
                            + selection, selectionArgs);
                }
                break;
            default:
                throw new IllegalArgumentException("Unknown URI: " + uri);
        }
        getContext().getContentResolver().notifyChange(uri, null);
        return rowsDeleted;
    }

    @Override
    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
        int uriType = sURIMatcher.match(uri);
        SQLiteDatabase sqlDB = database.getWritableDatabase();
        long id = 0;
        int rowsUpdated = 0;
        switch (uriType) {
            case EMAILS:
                rowsUpdated = sqlDB.update(EmailsSQLiteHelper.TABLE_EMAILS,
                        values,
                        selection,
                        selectionArgs);
                break;
            case EMAILS_ID:
                String idEmails = uri.getLastPathSegment();
                if (TextUtils.isEmpty(selection)) {
                    rowsUpdated = sqlDB.update(EmailsSQLiteHelper.TABLE_EMAILS,
                            values,
                            EmailsSQLiteHelper.COLUMN_ID + "=" + idEmails,
                            null);
                } else {
                    rowsUpdated = sqlDB.update(EmailsSQLiteHelper.TABLE_EMAILS,
                            values,
                            EmailsSQLiteHelper.COLUMN_ID + "=" + idEmails
                                    + " and "
                                    + selection,
                            selectionArgs);
                }
                break;
            default:
                throw new IllegalArgumentException("Unknown URI: " + uri);
        }
        getContext().getContentResolver().notifyChange(uri, null);
        return rowsUpdated;
    }
}










public class EmailsSQLiteHelper extends SQLiteOpenHelper {


    public static final String TABLE_EMAILS = "Emails";
    public static final String COLUMN_ID = "id";
    public static final String COLUMN_OD = "od";
    public static final String COLUMN_DATETIME = "dateTime";
    public static final String COLUMN_SUBJECT = "Subject";
    public static final String COLUMN_CONTENT = "Content";
    public static final String COLUMN_AVATAR = "avatar";


    private static final String DATABASE_NAME = "emails.db";

    private static final int DATABASE_VERSION = 1;

    private static final String DB_CREATE = "create table "
            + TABLE_EMAILS + "("
            + COLUMN_ID  + " integer primary key autoincrement, "
            + COLUMN_OD  + " text, "
            + COLUMN_DATETIME + " text, "
            + COLUMN_SUBJECT + " text, "
            + COLUMN_CONTENT + " text, "
            + COLUMN_AVATAR + " integer "
            + ")";


    public EmailsSQLiteHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }


    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(DB_CREATE);

    }


    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_EMAILS);
        onCreate(db);
    }

}

AnswerRe: java.lang.IllegalArgumentException: Unknown URI: content Pin
Richard MacCutchan23-Jun-20 21:59
mveRichard MacCutchan23-Jun-20 21:59 
Questionandroid Pin
Member 148497851-Jun-20 0:31
MemberMember 148497851-Jun-20 0:31 
QuestionRe: android Pin
David Crow5-Jun-20 2:43
MemberDavid Crow5-Jun-20 2:43 
QuestionI can't change lock screen wallpaper in my kotlin wallpaper app Pin
VipulSh28-May-20 5:59
MemberVipulSh28-May-20 5:59 
AnswerRe: I can't change lock screen wallpaper in my kotlin wallpaper app Pin
Richard MacCutchan28-May-20 6:22
mveRichard MacCutchan28-May-20 6:22 
GeneralRe: I can't change lock screen wallpaper in my kotlin wallpaper app Pin
VipulSh28-May-20 18:52
MemberVipulSh28-May-20 18:52 
GeneralRe: I can't change lock screen wallpaper in my kotlin wallpaper app Pin
Richard MacCutchan28-May-20 21:35
mveRichard MacCutchan28-May-20 21:35 
GeneralRe: I can't change lock screen wallpaper in my kotlin wallpaper app Pin
VipulSh28-May-20 21:37
MemberVipulSh28-May-20 21:37 
GeneralRe: I can't change lock screen wallpaper in my kotlin wallpaper app Pin
Richard MacCutchan28-May-20 21:43
mveRichard MacCutchan28-May-20 21:43 
QuestionPublishing A Xamarin Forms App Pin
Kevin Marois8-May-20 8:57
professionalKevin Marois8-May-20 8:57 
AnswerRe: Publishing A Xamarin Forms App Pin
Richard Deeming10-May-20 22:04
mveRichard Deeming10-May-20 22:04 
GeneralRe: Publishing A Xamarin Forms App Pin
Kevin Marois12-May-20 6:14
professionalKevin Marois12-May-20 6:14 
GeneralRe: Publishing A Xamarin Forms App Pin
Richard Deeming12-May-20 9:40
mveRichard Deeming12-May-20 9:40 
QuestionProblem in running Android app on IntelliJ IDEA Pin
Pouria Polouk6-May-20 10:34
MemberPouria Polouk6-May-20 10:34 
QuestionRe: Problem in running Android app on IntelliJ IDEA Pin
Richard MacCutchan6-May-20 23:03
mveRichard MacCutchan6-May-20 23:03 
AnswerRe: Problem in running Android app on IntelliJ IDEA Pin
Pouria Polouk7-May-20 8:23
MemberPouria Polouk7-May-20 8:23 
QuestionRe: Problem in running Android app on IntelliJ IDEA Pin
David Crow7-May-20 10:09
MemberDavid Crow7-May-20 10:09 
AnswerRe: Problem in running Android app on IntelliJ IDEA Pin
Pouria Polouk7-May-20 18:16
MemberPouria Polouk7-May-20 18:16 
GeneralRe: Problem in running Android app on IntelliJ IDEA Pin
Richard MacCutchan7-May-20 21:18
mveRichard MacCutchan7-May-20 21:18 
GeneralRe: Problem in running Android app on IntelliJ IDEA Pin
Pouria Polouk8-May-20 0:03
MemberPouria Polouk8-May-20 0:03 
GeneralRe: Problem in running Android app on IntelliJ IDEA Pin
Richard MacCutchan8-May-20 0:09
mveRichard MacCutchan8-May-20 0:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.