Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Test1
- {
- ...
- @JavascriptInterface
- public String method1()
- {
- String title = 1;
- return title;
- }
- }
- public class Test2
- {
- public void method2()
- {
- title //ошибка компиляции - переменная title не видна из этого блока кода
- }
- }
- public class Test1
- {
- ...
- @JavascriptInterface
- public String method1()
- {
- String title = 1;
- SharedPreferences pref = getApplicationContext().getSharedPreferences("MyPref", MODE_PRIVATE);
- SharedPreferences.Editor editor = pref.edit();
- editor.putString("key_name", title); // сохранение переменной
- return title;
- }
- }
- public class Test2
- {
- public void method2()
- {
- SharedPreferences pref = mContext.getApplicationContext().getSharedPreferences("MyPref", MODE_PRIVATE);
- String title = pref.getString("key_name", null);
- }
- }
Add Comment
Please, Sign In to add comment