3

I am getting the following Logcat error in my code for my application:

07-14 20:17:15.026: E/DatabaseUtils(814): Writing exception to parcel
07-14 20:17:15.026: E/DatabaseUtils(814): java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
07-14 20:17:15.026: E/DatabaseUtils(814):   at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:14608)

I tried so solve the issue by adding the following permission in the manifest, as stated in the error:

 <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"/>

However it is not solving the issue?

Relevant code:

Class attempting to transfer a DB file to SD card:

public class ExportDatabaseFileTask extends AsyncTask<String, Void, Boolean> {

    //Default constructor
    public ExportDatabaseFileTask() {
        
    }
    
    //delete if necessary
    //private final ProgressDialog dialog = new ProgressDialog(null);
    

    // can use UI thread here
    protected void onPreExecute() {
//      this.dialog.setMessage("Exporting database...");
//      this.dialog.show();
    }

    // automatically done on worker thread (separate from UI thread)
    protected Boolean doInBackground(final String... args) {

        //original database file location
        File dbFile = new File(Environment.getDataDirectory()
                + "/com.example.multapply/databases/MultapplyDatabase.db");

        //the destination file location
        File exportDir = new File(Environment.getExternalStorageDirectory(), "");
        if (!exportDir.exists()) {
            exportDir.mkdirs();
        }
        
        
        File file = new File(exportDir, dbFile.getName());
        try {
            file.createNewFile();
            this.copyFile(dbFile, file);
            return true;
        } catch (IOException e) {
            Log.e("mypck", e.getMessage(), e);
            return false;
        }
    }

    // can use UI thread here
    protected void onPostExecute(final Boolean success) {
//      if (this.dialog.isShowing()) {
//          this.dialog.dismiss();
//      }
//      if (success) {
//          Toast.makeText( null, "Export successful!", Toast.LENGTH_SHORT)
//                  .show();
//      } else {
//          Toast.makeText(null, "Export failed", Toast.LENGTH_SHORT).show();
//      }
    }

    void copyFile(File src, File dst) throws IOException {
        FileChannel inChannel = new FileInputStream(src).getChannel();
        FileChannel outChannel = new FileOutputStream(dst).getChannel();
        try {
            inChannel.transferTo(0, inChannel.size(), outChannel);
        } finally {
            if (inChannel != null)
                inChannel.close();
            if (outChannel != null)
                outChannel.close();
        }
    }

}

Instantiating this class:

/**
             * CRUD Operations
             * */
            // Inserting Contacts
            Log.d("Insert: ", "Inserting ..");
            
            db.addScore(new Score(UserName.getUserName(), score, System.currentTimeMillis() ));
            
            //attempting to export the file to the sd card
            ExportDatabaseFileTask task = new ExportDatabaseFileTask();
            task.execute();
            

FULL STACK TRACE OF ERROR:

07-14 21:48:00.903: E/DatabaseUtils(814): Writing exception to parcel
07-14 21:48:00.903: E/DatabaseUtils(814): java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
07-14 21:48:00.903: E/DatabaseUtils(814):   at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:14608)
07-14 21:48:00.903: E/DatabaseUtils(814):   at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2258)
07-14 21:48:00.903: E/DatabaseUtils(814):   at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:663)
07-14 21:48:00.903: E/DatabaseUtils(814):   at android.content.ContentProvider$Transport.call(ContentProvider.java:325)
07-14 21:48:00.903: E/DatabaseUtils(814):   at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:275)
07-14 21:48:00.903: E/DatabaseUtils(814):   at android.os.Binder.execTransact(Binder.java:404)
07-14 21:48:00.903: E/DatabaseUtils(814):   at dalvik.system.NativeStart.run(Native Method)
Community
  • 1
  • 1
RYJava2014
  • 81
  • 3
  • 9
  • please do a minimal research on your error. – njzk2 Jul 14 '14 at 20:03
  • possible duplicate of [Permission Denial: this requires android.permission.INTERACT\_ACROSS\_USERS\_FULL](http://stackoverflow.com/questions/20578474/permission-denial-this-requires-android-permission-interact-across-users-full) – njzk2 Jul 14 '14 at 20:03
  • The answer you have linked to does not actually solve the problem? – RYJava2014 Jul 14 '14 at 20:13
  • Is there any alternative solutions – RYJava2014 Jul 14 '14 at 20:15
  • 1
    my understanding here is that you are trying to copy a database from another application. you can't do that. for security reasons that I hope you understand. – njzk2 Jul 14 '14 at 20:28
  • Thanks, It is not actually from another application though, I am trying to copy the database file to the SD card on my device so that I can view it. It should work as it is outlined here: http://stackoverflow.com/questions/2814213/making-a-database-backup-to-sdcard-on-android and seems to work without the error I am getting? – RYJava2014 Jul 14 '14 at 20:37
  • `com.example.multapply` is the same app from which you run this code? also, post the complete stacktrace of the error. – njzk2 Jul 14 '14 at 20:45
  • and you should use `Context.getDatabasePath(String name)` to get the path to the database. instead of hardcoding the path like that. – njzk2 Jul 14 '14 at 20:47
  • thanks a lot for your help it is much appreciated, please see my edit with the full stack trace! – RYJava2014 Jul 14 '14 at 20:49
  • 1 sure thing is that you have to remove this permission from your manifest. – njzk2 Jul 14 '14 at 20:54
  • What permission do you mean? – RYJava2014 Jul 14 '14 at 20:54
  • the only one mentioned so far, `INTERACT_ACROSS_USERS_FULL`. Also, make sure you have the `WRITE_EXTERNAL_STORAGE` one. – njzk2 Jul 14 '14 at 20:56
  • Yeah i have removed it and have the other one in also. However, the same error is still persisting. it is very fustrating – RYJava2014 Jul 14 '14 at 20:58
  • there is no other log around the exception ? – njzk2 Jul 14 '14 at 20:59
  • that is the only log relating to the error – RYJava2014 Jul 14 '14 at 21:01
  • but what exactly happens, then? – njzk2 Jul 14 '14 at 21:01
  • The app just runs, it does not crash! – RYJava2014 Jul 14 '14 at 21:25
  • is there basically no solution to this? – RYJava2014 Jul 14 '14 at 21:25
  • if it does not crash, i am not sure I see where the issue is? – njzk2 Jul 14 '14 at 21:29
  • It is not actually transfering the database into the SD card folder where I want it to be? – RYJava2014 Jul 14 '14 at 21:38
  • Today I received this error after an SDK update of Android. In my manifest I had only `android.permission.WRITE_EXTERNAL_STORAGE` Logcat show me that I needed read permission `android.permission.READ_EXTERNAL_STORAGE` I added it and my problem was solved. – Pedro Varela Jan 15 '16 at 15:14

0 Answers0