![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Android studio
weixin_41144965
这个作者很懒,什么都没留下…
展开
-
Android studio 向手机存储写入txt内容
//path: 路径//Msg: 要写入的内容//isCover: 是否覆盖原有内容, true 覆盖, false 新增public static boolean writeFile(String path, String Msg, boolean isCover) {try {File file = new File(path);if (file.isDirectory()) {...原创 2020-04-14 23:22:06 · 3277 阅读 · 0 评论 -
Android studio 读取txt文件内容
//读取txt文件, 返回值永远不为null//注意要有存储权限public static String readFile(String path) {String result;try {File file = new File(path);//先读取info.txtif (!file.exists()) {return “”;}int length = (int) file....原创 2020-04-14 23:11:12 · 2950 阅读 · 0 评论 -
Android studio 获取SD卡根目录
//获取 SD 卡路径//注意: 最后有///注意: 从 Android 5.0 Lollipop 开始(SD卡只能读不能写)//注意添加存储权限////public static String getSdcardRootPath(Context context) {try {StorageManager storageManager = (StorageManager) cont...原创 2020-04-14 23:07:33 · 2655 阅读 · 0 评论 -
Android studio 获取一个随机数
获取一个随机数, 取值在 min--max 之间包括 min 和 maxpublic static int random(int min, int max) { if (min > max) { return (int) (max + (min - max + 1) * Math.random()); } return (int) (min + (m...原创 2020-04-14 22:59:36 · 2172 阅读 · 0 评论 -
Android studio 获取两数最大公约数
废话不多说, 直接给代码public static int getGreatestCommonNum(int a, int b) {if (a == b) {if (a == 0)return 1;elsereturn a;}int small = Math.min(a, b);if(small == 0)return 1;int big = Math.max(a, b);...原创 2020-04-14 22:51:57 · 372 阅读 · 0 评论