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";
工作得很好..
答案 0 :(得分:3)
getExternalStorageDirectory()
未定义为Context类型。它在Environment类中定义,它是一种静态方法。
答案 1 :(得分:1)
使用
String outPath = Environment.getExternalStorageDirectory(null).getAbsolutePath() + "/" +"a1.jpg";
而不是
String outPath = mContext.getExternalStorageDirectory(null).getAbsolutePath() + "/" +"a1.jpg";