`
wayfarer
  • 浏览: 294652 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Resources and Assets

阅读更多

在帮助文档中有关于资源文件的描述和解释,可以自己去查看。

 

1. 如何处理资源文件和*.db的数据库文件

  1. 在应用程序初始化时将raw中的db文件拷贝到/data/data/package_name/database/下,然后通过正常方式进行访问;但是只有用户拥有root权限,才有资格访问/data/data/package_name/目录。也就是说,我们开发的程序只能在有root权限的手机上才可以使用。
  2. 读取raw的文件:activity.getResources().openRawResource(id) //获得一个InputStream;
  3. 将资源文件放入SD卡,通过File、InputStream和OutputStream读取。

2. 资源文件大小限制:Asset限制文件大小UNCOMPRESS为1MB

      无论是使用Res\raw还是使用Asset存储资源文件,对文件大小有一个限制。在Emulator中不存在问题,但放到真机G1上时会出现问题,经过查看UNCOMPRESS_DATA_MAX的取值为1048576字节,除以1024不难发现是1MB 。也就是说GPhone在处理资源文件时不能大于1MB的体积(使用raw或asset存放的文件大小不能超过1048576字节),否则会在logcat下看到如下报错信息

      解决方法:将文件放入到sdcard(缺点:IO效率不好、耗电大、sd卡可移除);或者SQLite。下面是android开发社区的一个问题QA截取,从中可以看到如果想改变UNCOMPRESS_DATA_MAX ,只能重新编译android源代码。但是自己编译出来的android SDK并不会被GPhone手机厂商所采用,所以这个方法通过自己刷机,自己娱乐娱乐还是可以的。

  • Q: I am trying to load a file using resource. my file size is more than 1mb.
    res/raw: contains a file named abc_fb2. But i am getting UNCOMPRESS_DATA_MAX error in catlog.
    as per my google, i found that there might be asset.h file, which we need to change. with some more value like 3*1024*1024
    so kindly if any body suggest me that how to download the source code of android1.5 sdk. In i will be able to change.
  • A: This is baked into the Android framework. It's not something you canchange unless you're building your own platform.
    If the data is uncompressed and aligned (with zipalign) it can be memory-mapped directly, which is easier on the system than dedicating a large piece of physical memory to hold the entire uncompressed file. 

源代码编译修改UNCOMPRESS_DATA_MAX

修改/frameworks/base/include/utils/Asset.h,"UNCOMPRESS_DATA_MAX = 1 * 1024 * 1024" 改为 "UNCOMPRESS_DATA_MAX = 2 * 1024 * 1024"

  • 大小: 62.1 KB
  • 大小: 69.5 KB
分享到:
评论

相关推荐

    Android 资源与应用国际化

    1.源和资产(Resources and Assets) 2.Android 中可用的资源类型 3.Resources and Internationalization(资源和国际化) 4.本地化你的Android 应用程序 5.在Android 中轻松实现横竖屏的布局 6.如何获取当前Locale ...

    eoeAndroid特刊第五期 Android+widget pdf

    源和资产(Resources and Assets)  -大体介绍一下Android 上的资源系统  2. Android 中可用的资源类型  -Android 可以使用哪一些资源类型。  3. Resources and Internationalization(资源和国际化)  -...

    Android开发指南中文版

    资源和资产Resources and Assets 28 资源引用Resource Reference 43 国际化和本地化Internationalization and Localization 43 意图和意图过滤器Intents and Intent Filters 43 意图过滤器Intent filters 47 通常...

    Android开发宝典.rar

    资源和资产Resources and Assets 28 资源引用Resource Reference 43 国际化和本地化Internationalization and Localization 43 意图和意图过滤器Intents and Intent Filters 43 意图过滤器Intent filters 47 ...

    Android开发指南中文版-----应用程序框架

    资源和资产Resources and Assets 28 资源引用Resource Reference 43 国际化和本地化Internationalization and Localization 43 意图和意图过滤器Intents and Intent Filters 43 意图过滤器Intent filters 47 通常...

    android-sdk-2.1_r1.source

    Contains the resource classes used by standard Android applications. This package contains the resource... To learn more about how to use these classes, and what a resource is, see Resources and Assets.

    Android开发指南中文版.pdf 清晰版

    资源和资产Resources and Assets..................................... 28 资源引用Resource Reference..................................... 43 国际化和本地化Internationalization and Localization..............

    DisUnity v0.2.1 Unity3D资源提取

    disunity -c extract "resources.assets" If that doesn't work, try this: Code: java -jar disunity.jar "resources.assets" The files should then appear in a subfolder with the same name as the file. ...

    苹果AppStore 提交手册

    When you enroll, you become the primary contact for Apple, sign legal agreements, create your assets, and market your app. You’ll be asked whether you are an individual developer or a company. If you...

    Telerik控件英文使用说明

    Componentization of resources and grouping - you can combine and compress individual groups of web assets. CDN support. After testing your web site you can deploy your web assets on a Content ...

    Service Worker Development Cookbook(PACKT,2016)

    We’ll also teach you about cache functionality and assets to provide immediate load even over narrow connections. We conclude by giving you various tips to improve app performance, including the ...

    Game-Assets-And-Resources:2D游戏,3D游戏,手机游戏,Steam游戏,Unity游戏和其他游戏的免费和付费游戏资产和游戏资源

    免费游戏资产 本教程由编写。 Hotpot可帮助您创建引人入胜的, , , ,以及游戏,应用程序和扩展程序的其他图形。 该指南最初发布在,为方便开发人员并简化社区贡献而在此交叉引用。 概述 此页面记录了免费和付费...

    OTA COM Type Library

    Relations can be defined for user assets, tests, components, and resources. A relation can be defined between two entities of the same type or different types. Relations can be many-to-many. The ...

    android文件操作——读取assets和raw文件下的内容

    来自Resources和Assets 中的文件只可以读取而不能进行写的操作。 assets文件夹里面的文件都是保持原始的文件格式,需要用AssetManager以字节流的形式读取文件。 1. 先在Activity里面调用getAssets() 来获取...

    Digital Asset Management

    The author, Elizabeth Ferguson Keathley, is a board member of the DAM Foundation and has chaired both the Human Resources and Education committees. Currently Elizabeth is working with the University ...

    unity BuildReport Version 3.0.21

    Version 3.0.21(支持5.2.1以上版本) - FIX: Disabled fix for "Resources" assets size for Unity 5.2.1 (and greater) since Unity fixed it now.

    dexprotector-5.0.3

    Description DexProtector is designed for comprehensive protection of Android-applications against reverse engineering and ... Encryption of resources/assets Hiding of method calls Integrity control

Global site tag (gtag.js) - Google Analytics