//You can try this Context context = this; //or File f = File(UploadToServer.this.getCacheDir(), "filename");