Q: Is it programatically illegal to make a seperate Main Activity in Android Studio? My contacts list in Android Studio has a "Remove Contacts" tab that works as a Main Activity, having a Main_Remove_Contact class and a Remove_Contact class.
I would like to know if it's wrong to make a class that would be a Main Class in another project, but not on this one; can the app withstand a Main Activity and a "Main Activity"-like class. I'm saying this because of this error:
2022-02-09 08:36:32.966 6840-6840/com.example.wolfixfinal E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.wolfixfinal, PID: 6840
    java.lang.SecurityException: Permission Denial: writing com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts/data from pid=6840, uid=10160 requires android.permission.WRITE_CONTACTS, or grantUriPermission()
        at android.os.Parcel.createExceptionOrNull(Parcel.java:2373)
        at android.os.Parcel.createException(Parcel.java:2357)
        at android.os.Parcel.readException(Parcel.java:2340)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
        at android.database.DatabaseUtils.readExceptionWithOperationApplicationExceptionFromParcel(DatabaseUtils.java:165)
        at android.content.ContentProviderProxy.applyBatch(ContentProviderNative.java:599)
        at android.content.ContentProviderClient.applyBatch(ContentProviderClient.java:576)
        at android.content.ContentProviderClient.applyBatch(ContentProviderClient.java:564)
        at android.content.ContentResolver.applyBatch(ContentResolver.java:2196)
        at com.example.wolfixfinal.Main_Remove_Contact.onOptionsItemSelected(Main_Remove_Contact.java:55)
        at android.app.Activity.onMenuItemSelected(Activity.java:4269)
        at androidx.fragment.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:352)
        at androidx.appcompat.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:264)
        at androidx.appcompat.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:109)
        at androidx.appcompat.app.ToolbarActionBar$2.onMenuItemClick(ToolbarActionBar.java:66)
        at androidx.appcompat.widget.Toolbar$1.onMenuItemClick(Toolbar.java:221)
        at androidx.appcompat.widget.ActionMenuView$MenuBuilderCallback.onMenuItemSelected(ActionMenuView.java:781)
        at androidx.appcompat.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:834)
        at androidx.appcompat.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:158)
        at androidx.appcompat.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:985)
        at androidx.appcompat.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:975)
        at androidx.appcompat.widget.ActionMenuView.invokeItem(ActionMenuView.java:625)
        at androidx.appcompat.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:151)
        at android.view.View.performClick(View.java:7448)
        at android.view.View.performClickInternal(View.java:7425)
        at android.view.View.access$3600(View.java:810)
        at android.view.View$PerformClick.run(View.java:28305)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

One of the lines says
at com.example.wolfixfinal.Main_Remove_Contact.onOptionsItemSelected(Main_Remove_Contact.java:55)
The code of the method where the line is is the following:
@Override
    public boolean onOptionsItemSelected(MenuItem item){
        switch(item.getItemId()){
            case R.id.menu_refresh:
                showContacts();
                break;
            case R.id.menu_check:
                for(int i = 0; i < listView.getAdapter().getCount(); i++){
                    listView.setItemChecked(i,true);
                }
                break;
            case R.id.menu_delete:
                ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();

                ops.add(ContentProviderOperation.newDelete(ContactsContract.Data.CONTENT_URI).withSelection(ContactsContract.Data._ID + "=?", new String[]{String.valueOf(item)}).build());
                try {
                    getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
                } catch (OperationApplicationException e) {
                    e.printStackTrace();
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
                break;
        }
        return true;
    }

.applyBatch (in the try catch segment) is where the error is at. Does it have to do with the aforementioned Main Activity problem, or is it something else (it could be an outdated resource).
TL;DR:

*

*Question in the title

*Is applyBatch outdated?

*If not, how does it work in the method inserted above?

If more code is needed in the Main_Remove_Class activity, I'll edit the question. It does get some attributes from Remove_Class but I don't know if they're needed.
I think this question could also help with some specific IntelliJ Idea key-words, so I'll add that as a tag too. I might make a specific question about .applyBatch too if necessary.
Thanks in advance!
Edit: I already have the permission that asks the app if it can read contacts (android.permission.WRITE_CONTACTS).

A: Those activities are all fine.
You need to ask the user to grant the android.permission.WRITE_CONTACTS runtime permission for writing contacts:
This is the error:
java.lang.SecurityException: Permission Denial: writing com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts/data from pid=6840, uid=10160 requires android.permission.WRITE_CONTACTS, or grantUriPermission()

Dangerous permissions like WRITE_CONTACTS require you to ask the user for a permission at runtime. This means, just declaring the permission in the android manifest file is not enough.
Check out the guide on Request app permissions.
