android 怎么修改数据库

android 怎么修改数据库,第1张

These files will be ones that get deleted first when the device runs low on storage. There is no guarantee when these files will be deleted.

但是,最好不要依赖系统来管理,应该自己设定一个最大容量,当超出这个值时自己删除。

Context.getFilesDir(),Context.openFileOutput(String, int),Context.getFileStreamPath(String),Context.getDir(String, int)

/data/data/files

Android支持在SD卡上的应用私有目录,在Froyo版本后,通过getExternalFilesDir()可以获得具体路径。该路径依赖与应用的包名,如果你包为hello.file那么SD开上的应用私有目录为\mnt\sdcard\Android\data\hello.file\files\.

在使用SD卡目录时,需注意SD卡是否挂载,可通过Environment.getExternalStorageState()方法进行判断,如果返回值为Envirnment.MEDIA_MOUNTED表示SD卡处于挂载状态,可以放心使用。

getExternalCacheDir()和getCacheDir()比较

共同点:

files will be deleted when the application is uninstalled

不同点:

1、The platform does not monitor the space available in external storage, and thus will not automatically delete these files. Note that you should be managing the maximum space you will use for these anyway, just like with getCacheDir().

2、External files are not always available: they will disappear if the user mounts the external storage on a computer or removes it. See the APIs on Environment for information in the storage state.

3、There is no security enforced with these files. All applications can read and write files placed here.

Android系统内置一个Sqlite数据库,如果app需要使用Sqlite数据库数据库存储数据,Android会为此app生成一个.db文件。这个数据库在data/data/<package_name>/databases里面,其中<package_name>为该安卓app的工程包名,这个目录必须root后才能看到。在Windows,单机的应用程序,存储数据,基本放到一个文件里面,正如游戏的存档,基本就是把当前的游戏状态存到一个用户很难找到的文件里面。每次存档读档就是一个从这个存档文件读写数据的过程。由于Android系统内置一个Sqlite数据库,如果我们的app需要在手机上存储一些诸如游戏等数据,可以不用自己建立文件,之后利用读写文件的方法读写里面。可以直接利用sql语句,读写里面的数据,多用于读写一些用户对此app的配置。下面,举一个例子,说明Android中的Sqlite数据库增删改查如何进行增删改查。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/6646640.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-26
下一篇 2023-03-26

发表评论

登录后才能评论

评论列表(0条)

保存