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";

Error:The method getExternalStorageDirectory() is undefined for the type Context

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

works fine..

Amel Jose
  • 873
  • 2
  • 9
  • 22
  • Its static for the environment class not context http://stackoverflow.com/questions/5453708/android-how-to-use-environment-getexternalstoragedirectory – Vrashabh Irde Jun 22 '12 at 15:39

2 Answers2

3

getExternalStorageDirectory() is not defined for Context type. It is defined in Environment class and it is a static method.

nullpotent
  • 9,162
  • 1
  • 31
  • 42
1

use

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

instead of

String outPath = mContext.getExternalStorageDirectory(null).getAbsolutePath() + "/" +"a1.jpg";
ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213