0

In my app, I am calling camera that should capture picture and store it on given path:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
public static String pic_path =Environment.getExternalStorageDirectory().toString()+name;
File file = new File(pic_path);
Uri outputFileUri = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, REQUEST_CAMERA);

It works fine on devices that have SD card or any kind of External Storage. But it does not work on others (it crashes). So, what is alternative? How would I make this code work for devices without SD card/External Storage?

Zvone Peran
  • 53
  • 1
  • 11
  • 1
    "How would I make this code work for devices without SD card/External Storage?" -- name any device, made in the past 5 years, that does not have [external storage](https://commonsware.com/blog/2014/04/08/storage-situation-external-storage.html). "But it does not work on others (it crashes)" -- use LogCat to examine the Java stack trace associated with your crash: https://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this – CommonsWare Jan 16 '16 at 12:06
  • Sorry, I used wrong term when I said "device without External Storage". What I wanted to point out is situation when External Storage is unavailable, for example when there is no SD card. – Zvone Peran Jan 16 '16 at 12:36
  • External storage is not removable storage on the vast majority on Android devices. While there could be some current device model with removable external storage, I do not know of any. – CommonsWare Jan 16 '16 at 12:50
  • Maybe not new ones, but surely there are some of them which are 2 or 3 yeras old. – Zvone Peran Jan 17 '16 at 11:40
  • Take a look at http://stackoverflow.com/questions/15501355/getexternalstoragedirectory-not-working – Dalija Prasnikar Apr 22 '16 at 11:10

0 Answers0