Android: Retrieving shared preferences of other application

前端 未结 6 2088
迷失自我
迷失自我 2020-11-22 15:21

I have a settings application from which i have to retrieve other applications preferences, but i don\'t have the details of keys in them, how can i retrieve all the availab

6条回答
  •  执笔经年
    2020-11-22 16:01

    It can work if we want read perference value from other app/pkg/process. but there is something wrong in jkhouw1's answer:

    Context myContext = createPackageContext("com.example", 
                Context.MODE_WORLD_WRITEABLE);
    

    It should be :

    Context myContext = createPackageContext("com.example", 
                Context.CONTEXT_IGNORE_SECURITY);
    

    though , CONTEXT_IGNORE_SECURITY and MODE_WORLD_WRITEABLE with the same value of "int 2" At all ,thanks for this question and answers.

提交回复
热议问题