Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid ContentResolver.insert crashes with "unable to create new file"
    primarykey
    data
    text
    <p>I have a code inside some function of my activity:</p> <pre><code>ContentValues cv = new ContentValues(); cv.put(MediaStore.Images.Media.TITLE, "1354213408296.jpg"); ContentResolver contentResolver = getContentResolver(); Uri imageUri = contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, cv); Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); cameraIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); startActivityForResult(cameraIntent, 712984419/*Some request code*/); </code></pre> <p>It crashes with:</p> <pre><code>java.lang.IllegalStateException: Unable to create new file: /mnt/sdcard/DCIM/Camera/1354213408296.jpg at android.os.Parcel.readException(Parcel.java:1335) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:182) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:136) at android.content.ContentProviderProxy.insert(ContentProviderNative.java:415) at android.content.ContentResolver.insert(ContentResolver.java:730) </code></pre> <p>crashes on:</p> <pre><code>contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, cv); </code></pre> <p>The <code>"1354213408296.jpg"</code> is just <code>System.currentTimeInMillis() + ".jpg"</code>, so it is always unique</p> <p>The <code>android.permission.WRITE_EXTERNAL_STORAGE</code> is provided in manifest</p> <p>Here is some phone's environment specifications (I am using ACRA to get it):</p> <pre><code>getDataDirectory=/data getDownloadCacheDirectory=/cache getExternalStorageAndroidDataDir=/mnt/sdcard/Android/data getExternalStorageDirectory=/mnt/sdcard getExternalStorageState=removed getRootDirectory=/system getSecureDataDirectory=/data getSystemSecureDirectory=/data/system is4GConfig=true is8GConfig=false isEncryptedFilesystemEnabled=false isExternalStorageEmulated=false isExternalStorageRemovable=true </code></pre> <p>What can I do to prevent this crashes?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload