0
private Context mContext;


 public Upload(Context context, DropboxAPI<?> api, String dropboxPath) 
    {

        // We set the context this way so we don't accidentally leak activities
        mContext = context.getApplicationContext();

        String outPath = mContext.getExternalStorageDirectory(null).getAbsolutePath() + "/" +"a1.jpg";

错误:方法 getExternalStorageDirectory() 未为 Context 类型定义

String outPath = mContext.getExternalFilesDir("mnt/sdcard").getAbsolutePath() + "/" +"a1.jpg";

工作正常..

4

2 回答 2

3

getExternalStorageDirectory()没有为上下文类型定义。它在Environment类中定义,是一个静态方法。

于 2012-06-22T15:34:20.017 回答
1

采用

String outPath = Environment.getExternalStorageDirectory(null).getAbsolutePath() + "/" +"a1.jpg";

代替

String outPath = mContext.getExternalStorageDirectory(null).getAbsolutePath() + "/" +"a1.jpg";
于 2012-06-22T15:39:37.330 回答