導航:首頁 > 文件管理 > 安卓導入文件為什麼

安卓導入文件為什麼

發布時間:2022-12-31 06:38:37

安卓手機怎麼導入本地音樂(.mp3格式)

安卓系統導入音樂,需要使用電腦「發送到」功能。

具體操作步驟如下所示:

1、打開電腦,在電腦文件夾中,選擇需要導入的音樂文件。

Ⅱ 老師發的安卓文件代碼沒錯為什麼導入之後java文件裡面會有錯誤 改了工作空間也沒用

1、可以查看是否在編程過程中引入了外部的jar包,如果有的話就需要同樣的引入到你要運行的項目當中,而且還需要將jar包文件加入工作環境:右擊jar包,選擇build path--〉add to build path即可

如果真的是需要依賴包的,則需要先導入依賴項目包,然後再圖示中點擊右邊的add,即可添加。

Ⅲ Android項目導入所有文件都空了。本地文件都為空,求問為什麼

我也碰到過這樣的情況,是因為你更換了eclipse的位置?或者項目在遷移過程中受損了。但我總覺得這也算是一個bug,因為我有時候在來回切換不同項目space的時候竟也會導致這種情況。

Ⅳ 安卓導入文件夾會出錯怎麼解決 不管導入什麼都是這樣

可能是你的sdk版本低造成的,可以粘一下報錯的log;

Ⅳ 怎麼往android模擬器的sd卡里寫一個mp3文件呢,我用導入為什麼導入不進去呢

向SD卡中寫一個文件兩種方法:
一種方法 直接用DDMS手動導入 文件名不能有中文 大寫英文
二種方法 使用代碼,用文件流進行寫入 先將要導入的文件放在項目的assets目錄下
public String getSDPath(String fileNames) { //在SD中新建一個MP3文件 fileNames參數為文件名
File sdDir = null;
// 判斷sd卡是否存在
boolean sdCardExist = Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED);
if (sdCardExist) {
System.out.println("sd卡存在");
sdDir = Environment.getExternalStorageDirectory();// 獲取跟目錄
}
String fileName = sdDir.toString() + fileNames;
return fileName;
}
/*
* 拷貝文件到SD中
* filePath assets中文件路徑
*/
public String mergeFile(Context c, String filePath, String dst) {

File fileone = new File(dst);
System.out.println("dst文件是否存在" + fileone.exists());

if (!fileone.exists()) {
OutputStream out;
try {
out = new FileOutputStream(dst);

byte[] buffer = new byte[1024];
InputStream in;
int readLen = 0;
// 獲得輸入流 ,注意文件的路徑 此文件路徑為在程序的assets目錄下
in = c.getAssets().open(filePath);
while ((readLen = in.read(buffer)) != -1) {
out.write(buffer, 0, readLen);
}
out.flush();
in.close();
// 把所有小文件都進行寫操作後才關閉輸出流,這樣就會合並為一個文件了
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
System.out.println("dst 文件路徑 : " + dst);
return dst;
}

最後調用上面的方法 mergeFile(this,「要導入的MP3文件路徑」,getSDPath(「SD卡內新文件路徑」))

Ⅵ 安卓導入web html 文件快速讀寫方法

總所周知在安卓的資源文件中可以直接放入文件,webView 載入的時候可以直接調用(webview.loadUrl("file:///android_asset/"+文件名稱)),

但是assets 文件不支持寫入文件,如果我們要更新html 文件怎麼辦呢。

1、我們可以把初始版本html 文件壓縮到assets 下,然後在解壓到本地文件中去。如果後面有小的更新我們只需要根據文件MD5去更新

2、如果是大的更新我們只需要重新導入壓縮包到assets 下面打包即可。特別注意assets 文件壓縮直接最好檢查一下是否包含中文,不然會解壓不成功

/**/**

* 解壓縮功能.

* 將zipFile文件解壓到folderPath目錄下.

* ZipFile 解壓全部文件效率高於 ZipInputStream

* @throws Exception

*/

public static int upZipFile(File zipFile, String folderPath, ISiteFileManagetEvent event)throws IOException {

ZipFile zfile =new ZipFile(zipFile);

    Enumeration zList = zfile.entries();

    ZipEntry ze =null;

    byte[] buf =new byte[1024];

    int nowLength =0;

    while (zList.hasMoreElements()) {

ze = (ZipEntry) zList.nextElement();

        if (ze.isDirectory()) {

Log.e("upZipFile", ze.getName());

            String dirstr = folderPath + ze.getName();

            dirstr =new String(dirstr.getBytes("8859_1"), "GB2312");

            File f =new File(dirstr);

            f.mkdir();

continue;

        }

OutputStream os =new BufferedOutputStream(new FileOutputStream(getRealFileName(folderPath, ze.getName())));

        InputStream is =new BufferedInputStream(zfile.getInputStream(ze));

        int readLen =0;

        while ((readLen = is.read(buf, 0, 1024)) != -1) {

os.write(buf, 0, readLen);

        }

nowLength +=1;

        event.SiteFileManagetProcess(nowLength, 201);

        is.close();

        os.close();

    }

event.SiteFileManagetFinishEvent("");

    if (zipFile !=null) {

boolean delete = zipFile.delete();

        Log.e("BaseFileUtil1", delete +"");

    }

zfile.close();

    return 0;

}

/**

* 給定根目錄,返回一個相對路徑所對應的實際文件名.

*

* @param baseDir    指定根目錄

* @param absFileName 相對路徑名,來自於ZipEntry中的name

* @return java.io.File 實際的文件

*/

public static FilegetRealFileName(String baseDir, String absFileName) {

String[] dirs = absFileName.split("/");

    File ret =new File(baseDir);

    String substr =null;

    if (dirs.length >1) {

for (int i =0; i < dirs.length -1; i++) {

substr = dirs[i];

            try {

//substr.trim();

                substr =new String(substr.getBytes("8859_1"), "GB2312");

            }catch (UnsupportedEncodingException e) {

e.printStackTrace();

            }

ret =new File(ret, substr);

        }

if (!ret.exists())

ret.mkdirs();

        substr = dirs[dirs.length -1];

        try {

substr =new String(substr.getBytes("8859_1"), "GB2312");

        }catch (UnsupportedEncodingException e) {

e.printStackTrace();

        }

ret =new File(ret, substr);

        return ret;

    }

return ret;

}

* 復制zip 壓縮文件到 本地

* @param strOutFileName 本地文件路徑

* @param zipName        assets 文件名稱需要帶文件後綴 xx.zip

* @throws IOException

*/

public static void BigDataToSD(Context context, String strOutFileName, String zipName)throws IOException {

InputStream myInput;

    OutputStream myOutput =new FileOutputStream(strOutFileName);

    //操作assets 文件

    myInput = context.getAssets().open(zipName);

    byte[] buffer =new byte[1024];

    int length = myInput.read(buffer);

    while (length >0) {

myOutput.write(buffer, 0, length);

        length = myInput.read(buffer);

    }

myOutput.flush();

    myInput.close();

    myOutput.close();

}

閱讀全文

與安卓導入文件為什麼相關的資料

熱點內容
除了編程還有什麼技術 瀏覽:64
為什麼程序員討厭中文編程 瀏覽:338
數控車床編程g40是什麼意思 瀏覽:782
人們花錢為什麼逐漸網路化 瀏覽:272
如何用編程辦理電信業務 瀏覽:189
數控磨床小圓弧怎麼編程 瀏覽:390
桐鄉編程貓在哪裡 瀏覽:69
同一文件夾存儲大量文件 瀏覽:126
chrome修改js 瀏覽:842
用pad怎麼發word文件怎麼打開 瀏覽:465
哪個網站有幼 瀏覽:299
航班APP哪個最好 瀏覽:590
網路原創如何增強教育活力 瀏覽:527
蘋果第三方打開文件 瀏覽:310
蘋果電腦桌面移除的文件夾怎麼恢復 瀏覽:292
在文件名前添加字元 瀏覽:424
javaexcel導出控制項 瀏覽:484
怎麼樣粉碎文件 瀏覽:798
谷歌網站怎麼更新 瀏覽:934
svn命令行刪除文件夾 瀏覽:277

友情鏈接