跨平台读取sharedPreferences

if (tempFirstGame) {
            mAchievementManager.setFirstGame(false);
            Context otherAppsContext = null;
            try {
                otherAppsContext = this.createPackageContext(
                        "com.housedroid.android.puzzleworldfree", Context.CONTEXT_IGNORE_SECURITY);
            } catch (NameNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();

            }
            Log.d(TAG, "otherAppsContext: " + otherAppsContext.getPackageName());
            if(otherAppsContext != null){
                sharedPreferences = otherAppsContext.getSharedPreferences("PuzzleAchievementFreePrefs",Context.MODE_WORLD_READABLE);
                Log.d(TAG, "sharedPreferences: " + sharedPreferences+ " =========== "+sharedPreferences.contains(STAGE_NUMBER));
                stageNo = sharedPreferences.getInt(STAGE_NUMBER, 10);
                //mAchievementManager.setStageNo(stageNo); 
            }else{
                stageNo = 1;
                //mAchievementManager.setStageNo(stageNo); 
            }

 

posted on 2014-06-15 00:34  藤藤蔓蔓  阅读(258)  评论(0编辑  收藏  举报