zoukankan      html  css  js  c++  java
  • android将res中的资源拷贝到SD卡中

    //SD卡根目录

    String DATABASE_PATH = android.os.Environment.getExternalStorageDirectory().getAbsolutePath();

    try{

        ​    ​    ​//复制后在SD卡中的文件名是dataBase

                String databaseFilename = DATABASE_PATH + "/SYIMS/dataBase.db";

                File dir = new File(DATABASE_PATH);

                if (!dir.exists())

                    dir.mkdir();

                if (!(new File(databaseFilename)).exists()){

                    InputStream is = getResources().openRawResource(R.raw.database);

                    FileOutputStream fos = new FileOutputStream(databaseFilename);

                    byte[] buffer = new byte[8192];

                    int count = 0;

                    while ((count = is.read(buffer)) > 0){

                        fos.write(buffer, 0, count);

                    }

                    fos.close();

                    is.close();

                }

            }catch (Exception e){ 

            e.printStackTrace(); 

            }

  • 相关阅读:
    Hbase­优化方案
    ssh 登录
    微软2017校招笔试题3 registration day
    微软2017校招笔试题2 composition
    STL中的查找算法
    leetcode-188 买卖股票4
    leetcode-306 Additive Number
    网络安全(3): 数据完整性校验
    网络安全(2)-数据加解密
    linux共享库
  • 原文地址:https://www.cnblogs.com/xiao-xu/p/3407029.html
Copyright © 2011-2022 走看看