简体   繁体   中英

android APN How to read and write it?

i work on a app (> 4.4) and my boss would like to save the configuration of the APN into the SQLite (our database). As this, if the APN is lost for a reason we can retrieve easily these information and configure it ..

well, i've try some code but actually NOTHING work ... I have this error message

Java.Lang.SecurityException: No permission to write APN settings: Neither user 10081 nor current process has android.permission.WRITE_APN_SETTINGS.

Of course, i have added to the manifest the correct RIGTH as this

<uses-permission android:name="android.permission.READ_APN_SETTINGS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_APN_SETTINGS"></uses-permission>
<uses-feature android:name="android.hardware.telephony" android:required="false" />

And here is it my code, it's with xamarin android but if you have some code with android , no matter i can find the translatation ..

Android.Net.Uri APN_TABLE_URI = Android.Net.Uri.Parse("content://telephony/carriers");

        //path to preffered APNs
        Android.Net.Uri PREFERRED_APN_URI = Android.Net.Uri.Parse("content://telephony/carriers/preferapn");

        //
        Android.Database.ICursor cursor = ctx.ContentResolver.Query(PREFERRED_APN_URI, null, null, null, null);

Thanks guys for all your time you spend here for to share your knowledge

try to add these two permissions:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM