Note that there are some explanatory texts on larger screens.

plurals
  1. POIt can't access the sdcard after setting "android.uid.system" in my application?
    primarykey
    data
    text
    <p>This is a strange problem. My Application can access the sdcard successfully if I don't set <code>android.uid.system</code> to it. But after setting <code>android.uid.system</code> to it, my application can't access the sdcard. At this time, the exception take place:<code>07-13 09:11:24.999: INFO/System.out(9986): create file happen exception---&gt;java.io.IOException: Permission denied</code>. I check I write the right permission in the right place:</p> <pre><code>&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; &lt;uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /&gt;. </code></pre> <p>Because use <code>forceStopPackage</code> in my application, I need to add <code>android.uid.system</code> to the manifest. And I have written <code>LOCAL_CERTIFICATE := platform</code> in the make file. Who can explain this strange problem. After setting <code>android.uid.system</code>, my application is belong the system process which should have more power to access the sdcard. This is my idea. The following are my code:</p> <pre><code>public void setPackage(String dir){ System.out.println( "setPackage dir=="+dir ); File share=new File("/mnt/sdcard","test.txt"); if(!share.exists()){ try{ share.createNewFile(); }catch(Exception e){ System.out.println( "creat file happen exception---&gt;" +e.toString() ); } } try{ if(share!=null){ System.out.println( "create file is not null" ); FileOutputStream fops=new FileOutputStream(share); fops.write(dir.getBytes()); fops.flush(); fops.close(); } }catch(Exception e){ System.out.println( "write Exception--&gt;" +e.toString() ); } } </code></pre> <p>And My application run at the emulator and his target version is 2.3. Thank you very much.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload