Today, before I ran a project, I suddenly crashed as soon as I ran it. It felt very strange.
Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (Sqlite code 14): Could not open database, (OS error - 13:Permission denied)
seems to lack permissions according to the log prompt, because the project is only using storage, then look at the permissions in the androidmanifest.xml and see
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
these two permissions are in ah, this is what is the matter, baidu is not added under the permission. Finally, it suddenly occurred to me that my phone was running on Android6.0. Then, to verify it, I found a 4.0 system and ran it directly. Once I found the problem, I would solve it. Many permissions have appeared since Android6.0, even though they are configured in androidmanifest.xml, and must be requested manually, or the permissions must be turned on in Settings – applications – permissions.
after 6.0 system with some permissions can be carried out such operation:
public static final int REQUEST_EXTERNAL_STORAGE = 1;
private static String[] PERMISSIONS_STORAGE = {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
/**
* Verify access to the sd card
*
* @param activity
*/
public boolean verifyStoragePermissions(Activity activity) {
/*******below android 6.0*******/
if (Build.VERSION.SDK_INT < 23) {
return true;
}
int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.READ_EXTERNAL_STORAGE);
if (permission != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE);
return false;
} else {
return true;
}
}
Override in the Activity that invokes the requested permission.
/**
* :: Callbacks to request permissions
*
* @param requestCode
* @param permissions
* @param grantResults
*/
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_EXTERNAL_STORAGE) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
showToast("Authorization Success");
} else {
showToast("Authorization failed, please set open permissions.");
}
}
}
You can change the permission name to request another permission. Keep a small journal and hopefully help someone in need.
Read More:
- android.database.sqlite.SQLiteException: near “where”: syntax error (code 1): ,
- How to Fix Unknown error: Unable to build: the file dx.jar was not loaded from the SDK folder!
- How to solve MySQL error 1049 (42000): unknown database ‘database’
- Error: could not open `C:\Program Files\Java\jre1.8.0_211\lib\amd64\jvm.cfg’ (How to Fix)
- How to Fix Failed to open \EFI\BOOT\grubx64.efi Not Found
- How to Fix Error in module RSQL of the database interface
- PHP error Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0 Fatal error:
- Android has applied for permission and still prompts open failed: eacces (permission denied)
- How to Fix SQL Error: 1054, SQLState: 42S22 Unknown column ‘markcardex0_.art_service_time’ in ‘field list’
- yum install/update error: sqlite3.DatabaseError: database disk image is malformed
- How to Fix Session is not Connecting (How to Diagnose it)
- In SQLite database, set the default value for the field as the current time
- C programming interface of SQLite database (6) result codes and error codes
- Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded (How to Fix)
- How to Fix LDPlayer4 Proxy Setting Not Work Issue
- How to Fix Invalid bound statement (not found) Error
- How to Fix ”is not in the sudoers file“ in Linux
- VScode: How to Fix “Comments are not permitted in JSON” issue
- ERROR 1524 (HY000): Plugin ‘auth_socket’ is not loaded How to Fix
- How to Solve BFSVC Error: Could not open the BCD template store.