Monday, May 10, 2010

Unable to open trace file '/sdcard/Mytwitter.trace': Permission denied

in android, you can enable tracing by adding code like
Debug.startMethodTracing("mm.trace"); 
Stop tracingDebug.stopMethodTracing();
basically, tell the runtime to start and stop the logging behavior.  

after click and run the app for a while to cllock some data.
then the system will dump one big tracefile to /sdcard/mm.trace
at first, you may get error like
Unable to open trace file '/sdcard/mm.trace': Permission denied
when you view the permission, it's fine.
the trick is that start from 1.6, it need one permission so tat you could write something to sdcard
the permission is
android.permission.WRITE_EXTERNAL_STORAGE
public static final String WRITE_EXTERNAL_STORAGE
Since: API Level 4
Allows an application to write to external storage
Constant Value: "android.permission.WRITE_EXTERNAL_STORAGE"

reference: http://developer.android.com/guide/developing/tools/traceview.html

No comments:

 
Locations of visitors to this page