0

Environment.getExternalSourceDirectory is not working for Android 6. Is the problem due to encryption which is introduced in Marshmallow? How could I access my files as a file manager? My program goes like this:

public class MainActivity extends Activity { ListView lv; File f; ArrayAdapter<String> adapter; String[] s; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); lv=(ListView) findViewById(R.id.listView1); f=Environment.getExternalStorageDirectory(); s=f.list(); lv.setAdapter(adapter); } }

and my targeted sdk is as follows: android:targetSdkVersion="18

Abhishek
  • 1
  • 3
  • 1
    "Environment.getExternalSourceDirectory not working for Android 6" -- I am not aware of any method ever existing in Android, named `getExternalSourceDirectory()`, on `Environment`. Do you mean [`getExternalStorageDirectory()`](https://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory())? – CommonsWare Jun 20 '16 at 13:47
  • Yes I am new to programming in Android so a bit of error in function name – Abhishek Jun 20 '16 at 14:07
  • Please explain what "is not working" means. Also, you might wish to review https://stackoverflow.com/questions/32635704/android-permission-doesnt-work-even-if-i-have-declared-it and https://stackoverflow.com/questions/32789157/how-to-write-files-to-external-public-storage-in-android-so-that-they-are-visibl – CommonsWare Jun 20 '16 at 14:13

0 Answers0