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(); 

            }

  • 相关阅读:
    752.打开转盘锁
    733. 图像渲染
    704.二分查找
    leetcode 87 Scramble String
    找实习总结
    leetcode 44 Wildcard Matching
    Linux,网络编程接口记录
    leetcode 172 Factorial Trailing Zeroes
    leetcode 168 Excel Sheet Column Title
    leetcode 65 Valid Number
  • 原文地址:https://www.cnblogs.com/xiao-xu/p/3407029.html
Copyright © 2011-2022 走看看