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

            }

  • 相关阅读:
    HDU4777 Rabbit Kingdom
    HDU6200 mustedge mustedge mustedge
    HDU6187 Destroy Walls
    最长公共上升子序列的学习
    关于约瑟夫问题的学习
    洛谷1602 Sramoc问题
    HDU2089 不要62
    poj3532 Round Numbers
    洛谷1014 Cantor表
    花盆Flowerpot[USACO12MAR]
  • 原文地址:https://www.cnblogs.com/xiao-xu/p/3407029.html
Copyright © 2020-2023  润新知