首页 > 解决方案 > 数据存储安全

问题描述

我想保证数据的安全。只能从我的应用程序访问,我希望即使您路由Android,也无法从外部访问并且无法更改。

我正在搜索'FileOutputStream fos = openFileOutput (FILE_NAME, Context.MODE_PRIVATE);'

这是最好的方法吗?

标签: androidsecurity

解决方案


这将有所帮助:https ://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html https://www.tutorialspoint.com/java/java_encapsulation.htm http://tutorials.jenkov.com/ java/access-modifiers.html

访问修饰符和封装可帮助您防止其他类/方法访问事物或限制对某些类/方法的访问。

但我相信在你的情况下,你会想让你的变量有访问修饰符。在类的顶部写下这些变量:

private FileOutputStream writetofile;// This variable is private and can only be accessed within the class.
private final String location; //This is the location of where you are saving to. Because it is final it will always save to that location

推荐阅读