Welcome! Log In Create A New Profile

Advanced

Android 11 file access error. WM27-28

Posted by cabinetman 
Android 11 file access error. WM27-28
May 04, 2023 09:07PM
Hello All,

I have an app that use local HF data files to store data on Android 11, out of the blue I get an error when try on connect to the data files. I have had this app on about 30 devices for about 5 years now. The only fix is to uninstall the app delete the data folder and reinstall. Error 70152 is an access issue.

Has anyone seen this?

Date and time=04/05/2023 10:49:45
Message=Unable to open the </storage/emulated/0/Documents/CTBarcode/DataFiles/barcodes.fic> file.
System message=What happened?
Unable to open the </storage/emulated/0/Documents/CTBarcode/DataFiles/barcodes.fic> file.

Error code: 70152
Level: fatal error
WD55 error code: 152

System error code: 13
System error message:
Permission denied
Module: libwd280hf.so (01A280075r - 28.0.382.1)

Thank you DW
Re: Android 11 file access error. WM27-28
May 05, 2023 09:29AM
Hi cabinetman,

It looks like a file access problem ...

1. If you haven't looked at: [help.windev.com]
it is worth reading - a lot of things have changed with Android 11 and file access.

2. If you are using an external SD then the SD card may have a problem ...
Also make sure that you are NOT accesing/updating the files in the SD with another application

3. Take a look here for more ideas: [developer.android.com]

Regards
Steven Sitas
Re: Android 11 file access error. WM27-28
May 05, 2023 10:05AM
Hi Cabinetman

Since Android 10 or 11, the storage security and access has changed.
You need to take this into account.

Let me check in my coding on how to define this and come back to some sample code.
If I recall correctly, there's also a FAQ on the PC$ website.
https://faq.pcsoft.fr/21548-faq-read.awp

And here's a code snippet from a common mobile app class that sets the app data root location in the global member DATA_Path of the class:
//Path - ANDROID 
<COMPILE IF TypeConfiguration=Android>
	//As of Android 11, fDataDir(), fExeDir(), fCacheDir, etc return
	// 		/data/user/0/com.company.appname/...
	//This folder is only accessible on a rooted device which is something that we don't 
	//want for our WMS solutions. In this case we create a generic accessible app folder
	IF SysNbExternalStorage() >= 1 THEN
		IF SysStatusExternalStorage(1) = sseAvailable THEN
			DATA_Path = SysDirExternalStorage(1,sseAppFile) + [fSep]
		END
	END
<END>


Cheers

Peter H.



Edited 5 time(s). Last edit at 05/05/2023 10:56AM by PeHoBe.
Re: Android 11 file access error. WM27-28
May 05, 2023 05:40PM
Hello Steven and Peter,

I was using the Public documents for the storage of the data files.(I thought was something that should be okay)
mo_StoragePath  = SysDirExternalStorage(1,ssePublicDocument)+[fSep]+StorageFile

I have 25 scanners that are used every day and they have been working this way for a year and a half. Out of the blue I get one from time to time that have this issue.

If I uninstall the app and try to copy the locked files back to the Public Documents folder I still get the permissions error.

If I uninstall the app delete the files and let code recreate new ones in the Public Documents folder it works fine.

I just find this to be strange I thought using the Public Document folder was okay to do.


I used Peter's sample code and change the file storage location to the sseAppDocument and was able to copy the locked files into the app folder and everything works again.

Thanks for your help.
DW
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: