0

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

tapastoutvu
  • 59
  • 1
  • 11
  • this should help you http://stackoverflow.com/questions/13453640/read-apns-in-android-4-2 – an_droid_dev Feb 24 '17 at 12:45
  • Hello guy, thanks for the links i've read the topic but nothing work every time i have the same problem about the permission ...I'm not sure but i think since version > 4 it's NOT ALLOW to create, update these information ...Could you confirm this ? thanks – tapastoutvu Feb 27 '17 at 15:07

1 Answers1

0

try to add these two permissions:

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