当前位置: 首页 > 编程日记 > 正文

android逆向分析概述_Android存储概述

android逆向分析概述

Storage is this thing we are all aware of, but always take for granted. Not long ago, every leap in storage capacity was incremental and appeared to be impossible. Nowadays, we don’t give a second thought when contemplating how much of it our devices have (and couldn't care less about the differences).

存储是我们都知道的事情,但始终是理所当然的。 不久前,存储容量的每一次飞跃都是递增的,似乎是不可能的。 如今,当我们考虑我们的设备有多少(并且不会在乎差异)时,我们不会再三思。

A bigger point would be to look at the evolution of what is stored in memory. Before smartphones, we saved the occasional photo or two, some games and a ton of text messages. But now, any standard phone will have a concoction of applications, documents, photos, videos, music files, and more. Let’s find out how we can utilize a devices's storage space for our applications.

更大的一点是要查看存储在存储器中的内容的演变。 在使用智能手机之前,我们偶尔会保存一两张照片,一些游戏和大量短信。 但是现在,任何标准手机都可以混合应用程序,文档,照片,视频,音乐文件等。 让我们找出如何为我们的应用程序利用设备的存储空间。

What we’re going to cover in this article is:

我们将在本文中介绍的是:

  1. The different types of storage on Android phones

    Android手机上的不同存储类型
  2. Differences between the types of storage

    存储类型之间的差异
  3. How to use storage in your application

    如何在应用程序中使用存储

Each application has access to two different types of storage: internal and external. There are major differences between these two types of storage, and knowing them will help you when designing your next application.

每个应用程序都可以访问两种不同类型的存储: internalexternal 。 这两种类型的存储之间存在主要差异,了解它们将在设计下一个应用程序时为您提供帮助。

Before we begin, one thing must be said about storage and cache. Storage is meant for things you want to save persistently, while cache is there to save things temporarily.

在开始之前,必须先谈一谈存储和缓存。 存储用于要永久保存的内容,而缓存则用于临时保存内容。

内部存储器 (Internal Storage)

When each application is run on the operating system, it has its own internal storage. This storage is private and only for the use of the application. Meaning, other applications cannot access it, nor can the user. Another thing to keep in mind when using internal storage is the availability of it. Unlike external storage, internal storage is always available for your application.

当每个应用程序在操作系统上运行时,它都有自己的内部存储。 此存储是私有的,仅供应用程序使用。 这意味着其他应用程序无法访问它,用户也无法访问它。 使用内部存储时要记住的另一件事是它的可用性。 与外部存储不同,内部存储始终可用于您的应用程序。

Using this storage has its drawbacks, though. If the user removes the application, all the data stored in your app's internal storage is removed as well. Imagine what would happen if you installed a game on your phone and somewhere down the road decided to remove it. You would like to have your game progress saved, if by any chance you would install the game again.

但是,使用此存储有其缺点。 如果用户删除该应用程序,则存储在您应用程序内部存储器中的所有数据也将被删除。 想象一下,如果您在手机上安装了游戏,但后来决定将其删除,将会发生什么情况。 您希望保存游戏进度,如果有机会再次安装游戏。

So, how do we save a file to internal storage?

那么,我们如何将文件保存到内部存储中?

As you can see in the code example, we are saving a file called hello_world_file that contains the text, “Hello From Internal Storage!”. I have created two catch clauses just to demonstrate the exceptions that may occur when trying to do this, but you can minimize them to one catch clause with the general Exception object.

在代码示例中可以看到,我们正在保存一个名为hello_world_file的文件,其中包含文本“ Hello From Internal Storage!”。 。 我创建了两个catch子句只是为了演示尝试执行此操作时可能发生的异常,但是您可以使用常规Exception对象将它们最小化为一个catch子句。

Pay attention that the method openFileOutput will open the file if it already exists, but if not, will create it. The second parameter to this method is the file mode. This parameter designates the scope of the file and access to it. The default value is MODE_PRIVATE, which makes the file accessible to your application only.

请注意,如果文件已经存在,则openFileOutput方法将打开该文件,但如果不存在,则将创建该文件。 此方法的第二个参数是文件模式。 此参数指定文件的范围和对其的访问。 默认值为MODE_PRIVATE,这使该文件只能由您的应用程序访问。

The other two values for this parameter are MODE_WORLD_READABLE and MODE_WORLD_WRITEABLE, but they have been deprecated since API 17. Sharing private files with other applications uses a different set of logic that you can read more about here. Finally, when writing to the file, we convert our string to bytes and we make sure to close the file at the end.

此参数的其他两个值是MODE_WORLD_READABLE和MODE_WORLD_WRITEABLE,但是自API 17开始不推荐使用。与其他应用程序共享私有文件使用一组不同的逻辑,您可以在此处了解更多信息。 最后,在写入文件时,我们将字符串转换为字节,并确保最后关闭文件。

外置储存 (External Storage)

Contrary to what the name implies, this is storage that is defined by the fact that it is not always accessible. This may mean that it can be an external SD card (secondary external storage), but it can also be storage found on the device (primary external storage).

与名称所暗示的相反,这是由于存储并不总是可访问而定义的。 这可能意味着它可以是外部SD卡(辅助外部存储),但也可以是设备上的存储(辅助外部存储)。

To bring the fact home, external storage is storage that can be accessed when you connect your device to a computer via a USB cable. As you may have guessed, anything stored in this type of storage is accessible to other applications on your device, but will be kept if you uninstall the application.

为了将事实带回家,外部存储是当您通过USB电缆将设备连接到计算机时可以访问的存储。 您可能已经猜到,存储在该类型存储中的所有内容都可以被设备上的其他应用程序访问,但是如果您卸载该应用程序,则这些内容将保留。

Before we can demonstrate how to save files to the external storage, we need to do two things:

在演示如何将文件保存到外部存储之前,我们需要做两件事:

  1. Make sure there is enough space there to save the file

    确保那里有足够的空间来保存文件
  2. Ask for permission during runtime

    在运行时寻求许可

Making sure there is enough storage space requires the following lines of code:

确保有足够的存储空间,需要以下代码行:

To get access to the external storage, we need to add the following permission to our AndroidManifest.xml:

要访问外部存储,我们需要向AndroidManifest.xml添加以下权限:

Furthermore, since API 23, dangerous permissions aren’t authorized during install time, but during runtime. Writing to external storage is categorized as one, so we need to add logic to allow the user to decide whether to grant the application permission or not.

此外,由于使用API​​ 23,危险权限不会在安装时授权,而是在运行时授权。 写入外部存储归为一类,因此我们需要添加逻辑以允许用户决定是否授予应用程序许可。

Our writeFileToExternalStorage looks like this:

我们的writeFileToExternalStorage看起来像这样:

If you want to see an example of all the code presented here, you can head over to this GitHub repository.

如果您想查看此处提供的所有代码的示例,可以转到GitHub存储库 。

很高兴知道 (Good To Know)

Above were just two simple examples of how to work with the different types of storage for your application. Since we are dealing with a resource that the system manages, we should also be aware of the behaviors associated with it.

上面仅是两个简单示例,说明如何为您的应用程序使用不同类型的存储。 由于我们正在处理系统管理的资源,因此我们还应该注意与之相关的行为。

By default, your application will be installed to internal storage (see internalOnly explanation), but from API level 8, you can add an attribute, installLocation, to your manifest that lets your application be installed to external storage. One reason for doing so is if your application is very large, and you would prefer the user to install it on the device’s external storage since there is more space there.

默认情况下,您的应用程序将安装到内部存储( 请参阅internalOnly说明 ),但是从API级别8开始,您可以在清单中添加属性installLocation ,以将应用程序安装到外部存储。 这样做的原因之一是,如果您的应用程序非常大,并且您希望用户将其安装在设备的外部存储上,因为那里有更多空间。

There are three values for this attribute:

此属性有三个值:

  • auto - means that you don’t have a specific preference where the application will be installed. The application will try to be installed to internal storage, but if it is full, it will install it inside external storage

    自动 -表示您没有安装应用程序的特定首选项。 该应用程序将尝试安装到内部存储中,但是如果已满,它将安装在外部存储中

  • internalOnly - the application will only be installed to internal storage, and if there isn’t enough space there, it will not be installed

    internalOnly-该应用程序将仅安装到内部存储中,并且如果那里没有足够的空间,则不会安装该应用程序

  • preferExternal - means that you want your application to be installed to external storage, but if there is not enough room there, it will be installed internally

    preferredExternal-表示您希望将应用程序安装到外部存储中,但是如果那里没有足够的空间,它将在内部安装

For both the auto and the preferExternal options, the user has the option of moving the application from external storage to internal, and vice versa.

对于auto和preferredExternal选项,用户可以选择将应用程序从外部存储移动到内部,反之亦然。

Keep in mind that once a user connects their device to a computer and enables it to share data or unmounts an SD card, all applications running from the external storage are destroyed. If your application uses one of the following features, you should not install it to external storage:

请记住,一旦用户将其设备连接到计算机并使其能够共享数据或卸载SD卡,从外部存储运行的所有应用程序都会被破坏。 如果您的应用程序使用以下功能之一,则不应将其安装到外部存储中:

Various services (alarm services in particular), Input Method Engines, Live Wallpapers, Application Widgets, Account Managers, Sync Adapters, Device Administrators and Broadcast receivers listening for boot completed.

各种服务( 尤其是 警报服务 ),输入法引擎,动态壁纸,应用程序小部件,帐户管理器,同步适配器,设备管理员和侦听引导的广播接收器已完成。

翻译自: https://www.freecodecamp.org/news/an-overview-of-android-storage/

android逆向分析概述

相关文章:

小程序地图的使用笔记

这两天在看小程序的地图,写写笔记记录一下 小程序官方文档提供的方法 https://mp.weixin.qq.com/debug/wxadoc/dev/api/location.html 腾讯地图提供的jssdk http://lbs.qq.com/qqmap_wx_jssdk/qqmapwx.html 根据提示使用腾讯地图jssdk需要申请,在实例化的…

JS 实现可停顿的垂直滚动

1 var ScrollMiddle {2 Odiv:document.getElementById(comment), // 目标DOM 3 Oli: document.getElementById(comment).getElementsByTagName(li), 4 times:30, // 配置滚动时间 …

uniapp 上拉加载更多完整实现源码

直接上代码 <template><view class"searchList"><!-- 搜索框 --><Search></Search><img class"top_img" src"/static/image/dataDelivery.png" /><view class"menus p_r"><view class&…

todoist 无法登陆_通过构建Todoist克隆将您的React技能提升到一个新的水平

todoist 无法登陆In this intermediate React course from Karl Hadwen, you will learn how to create the popular Todoist application from scratch using React, Custom Hooks, Firebase & the React Testing Library. You will lean how to use SCSS to style the ap…

w3cscholl的在线代码编辑工具

https://www.w3cschool.cn/tryrun/runcode?langc转载于:https://www.cnblogs.com/jhj117/p/7804133.html

点击事件加锁封装

看代码 // 提交答案 btnReply() {if (!this.$clickLock) returnthis.changeClickLock() } 封装代码 // 点击事件加锁 使用方式&#xff0c;在点击时加入以下代码// if (!this.$clickLock) return// this.changeClickLock()that.changeClickLock () > {that.$clickLock f…

WinCE 7 Mouse HOOK

WinCE 5.0&6.0 的鼠标 HOOK&#xff0c;偶在本博客中已经写过文章。WinCE7.0 的下的鼠标 HOOK 实现&#xff0c;完全和 WinCE 6 是一样的。 效果&#xff1a;在 WinCE 系统界面可以 HOOK 住鼠标的操作。 但是在 Silverlight 应用的界面&#xff0c;HOOK 功能失效。转载于:h…

devops和docker_通过免费的2小时Docker课程学习DevOps基础知识

devops和dockerDocker is a powerful DevOps tool for putting your apps into "containers." Docker是功能强大的DevOps工具&#xff0c;可将您的应用程序放入“容器”中。 You can run these same containers anywhere - on your laptop, on a server - even on a…

生成24位字符串ID__IdGenerator.java

此工具类用于生成24位字符串ID&#xff0c;唯一不重复。 直接通过 IdGenerator.get() 获取。 源码如下&#xff1a;(点击下载源码 - IdGenerator.java ) 1 import java.net.NetworkInterface;2 import java.nio.ByteBuffer;3 import java.nio.ByteOrder;4 import java.util.Enu…

IDEA构建一个mybatis项目

目录结构如下&#xff1a; 在pom.xml中配置需要的jar包 <dependencies><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>3.3.0</version></dependency><dependency><gro…

小程序在canvas上层做图片滚动

实现该功能踩过的坑 1.swiper的swiper-item中image图片无法在canvas的上层显示&#xff0c;会被canvas 覆盖 2.swiper的swiper-item 里面放 cover-image 会样式错乱 3.scroll-view里面放 cover-image 会样式错乱 解决方案&#xff1a;使用CSS样式实现&#xff0c;超出部分隐…

React是如何在后台运行的

React is a very popular JavaScript library. With over 5.5 million weekly downloads, React is enjoying great popularity. But not a lot of React developers know how React works under the hood. React是一个非常流行JavaScript库。 每周的下载量超过550万&#xff0…

H5播放视频流

代码 <html> <head> <title>视频直播</title> <meta charset"utf-8"> <link href"http://vjs.zencdn.net/5.5.3/video-js.css" rel"stylesheet"> <!-- If youd like to support IE8 --> <!-…

获取Java系统相关信息

1 package com.test;2 3 import java.util.Properties;4 import java.util.Map.Entry;5 6 import org.junit.Test;7 8 public class SystemTest {9 10 /** 11 * 获取Java系统相关信息 12 * throws Exception 13 */ 14 Test 15 public void testSys…

如何使用FaunaDB + GraphQL

I have one or two projects I maintain on Netlify, in addition to hosting my blog there. It’s an easy platform to deploy to, and has features for content management (CMS) and lambda functions (by way of AWS).除了在其中托管我的博客外&#xff0c;我在Netlify上…

POJ 1414 Life Line(搜索)

题意&#xff1a; 给定一块正三角形棋盘&#xff0c;然后给定一些棋子和空位&#xff0c;棋子序号为a&#xff08;1<a<9)&#xff0c;group的定义是相邻序号一样的棋子。 然后到C&#xff08;1<N<9&#xff09;棋手在空位放上自己序号C的棋子&#xff0c; 放完后&a…

MySQL_数据库操作语句

ZC&#xff1a;数据库名/表名/字段名 都使用小写字母 1、 创建 数据库 和 表 的时候&#xff0c;都要指定 编码方式为 utf-8 ! ! ! 因为 执行命令“show variables like char%;”后可以看到 character_set_database 的值为 latin1&#xff0c;即 默认创建数据库是使用的 字符编…

H5打开预览PDF,PPT等文件

实现代码&#xff1a; pdfUrl 写你的文件路径 <iframe :src"//www.xdocin.com/xdoc?_functo&_formathtml&_cache1&_xdocpdfUrl"width"100%"height"100%"frameborder"0"> </iframe> 可以直接打开看

广播代码_代码广播:专为编码而设计的24/7音乐

广播代码阅读本文时&#xff0c;您可以继续阅读Code Radio。 (You can go ahead and start listening to Code Radio while you read this) Most developers I know listen to music while they code. When the meetings are over, the headphones come out.我认识的大多数开发…

从 Android 静音看正确的查bug的姿势?

0、写在前面 没抢到小马哥的红包&#xff0c;无心回家了&#xff0c;回公司写篇文章安慰下自己TT。。话说年关难过&#xff0c;bug多多&#xff0c;时间久了难免头昏脑热&#xff0c;不辨朝暮&#xff0c;难识乾坤。。。艾玛&#xff0c;扯远了&#xff0c;话说谁没踩过坑&…

SecureCRT中sqlplus,使用Backspace删除时 ^H^H

在“Session Options” - "Terminal" - "Mapped Keys" - "Other mappings"&#xff0c;选择“Backspace sends delete”。转载于:https://www.cnblogs.com/Clark-cloud-database/p/7813867.html

在vue中使用vuex,修改state的值示例

1、 安装 vuex npm install vuex -S 2、在目录下创建store文件 3、 在store.js编辑一个修改state的方法 然后在mian.js中全局引入 最后在组件中使用 这个的功能是运用mutations 修改state中的值

软件开发 自由职业_自由职业? 这里有7个可以出售软件开发服务的地方

软件开发 自由职业Web developers need clients. This is true whether you are a full-time freelancer or you freelance on the side.Web开发人员需要客户。 无论您是全职自由职业者&#xff0c;还是身旁的自由职业者&#xff0c;都是如此。 So if youve ever asked: "…

生成SSH key

1、打开终端&#xff0c;输入下面的代码 &#xff0c;注意&#xff1a;$your_email为占位符&#xff0c;此处输入你自己的email ssh-keygen -t rsa -C "$your_email" 2、查看生成的公钥&#xff0c;输入下面的代码 cat ~/.ssh/id_rsa.pub 3、复制公钥&#xff08;公钥…

[转载]二叉树(BST,AVT,RBT)

二叉查找树(Binary Search Tree)是满足如下性质的二叉树&#xff1a;①若它的左子树非空&#xff0c;则左子树上所有结点的值均小于根结点的值&#xff1b;②若它的右子树非空&#xff0c;则右子树上所有结点的值均大于根结点的值&#xff1b;③左、右子树本身又各是一棵二叉查…

Invalid Host header 问题解决

出现该问的原因&#xff1a; 因为新版的 webpack-dev-server 出于安全考虑&#xff0c;默认检查 hostname&#xff0c;如果hostname不是配置内的就不能访问。 解决办法&#xff1a;设置跳过host检查 打开你的项目全局搜索 devServer &#xff0c;在 devServer 里面添加 &quo…

react hooks使用_为什么要使用React Hooks?

react hooks使用The first thing you should do whenever youre about to learn something new is ask yourself two questions -每当您要学习新东西时&#xff0c;应该做的第一件事就是问自己两个问题- Why does this thing exist? 为什么这东西存在&#xff1f; What probl…

算法 - 字符串匹配

http://blog.csdn.net/linhuanmars/article/details/20276833 转载于:https://www.cnblogs.com/qlky/p/7817471.html

工作流入门链接

百度百科-工作流 http://baike.baidu.com/link?urlZjElBNByyZz_ItLtd_Uqt3Sadcwv0-4CDO806vKQWJDuUOFybbkzpg8GOB1EU71w8bT4x64RoRXBrFXa7o_dK 企业应用工作流的好处http://jingyan.baidu.com/article/90895e0fe9c56164ec6b0b24.html工作流管理的好处http://blog.sina.com.cn/…

uniapph5配置index.html模板路径不生效解决办法

很简单&#xff0c;关闭应用再重新启动试试&#xff0c;还不行的话&#xff0c;重启IDE