當前位置:首頁 » 安卓系統 » android指定文件路徑

android指定文件路徑

發布時間: 2022-06-22 06:07:04

① 如何讀取SD卡CSV文件或指定的路徑在android系統

android手機獲取自帶存儲路徑和sd卡存儲路徑的方式是:調用Environment.getExternalStorageDirectory(),返回的存儲目錄並不是系統內置的SD卡目錄。
1.一部分手機將eMMC存儲掛載到 /mnt/external_sd 、/mnt/sdcard2 等節點,而將外置的SD卡掛載到 Environment.getExternalStorageDirectory()這個結點。
此時,調用Environment.getExternalStorageDirectory(),則返回外置的SD的路徑。
2.而另一部分手機直接將eMMC存儲掛載在Environment.getExternalStorageDirectory()這個節點,而將真正的外置SD卡掛載到/mnt/external_sd、/mnt/sdcard2 等節點。
此時,調用Environment.getExternalStorageDirectory(),則返回內置的SD的路徑。

② android系統中的app安裝後的各個文件路徑在哪裡

在系統中system/app文件夾中。
在android系統中安裝軟體時,系統會將其安裝在設定好的路徑當中,即system/app路徑。後來下載的APP可以卸載,但系統自帶的APP不能卸載,否則會引發系統的崩潰。
在安裝APP時,也可以直接將文件復制到手機里(手機內存、Storage
Card都可以),在手機上執行該CAB文件即可安裝。
(2)android指定文件路徑擴展閱讀
android系統中的app不同格式安裝:
1、CAB格式,直接將文件到手機里,都可以在手機上執行該CAB文件即可安裝。
2、EXE格式,EXE格式的程序可分為手機上直接運行(即綠色軟體的形式)和連接電腦同步安裝2種形式。
3、免安裝軟體(綠色軟體),將文件直接拷貝到手機里(手機內存、Storage
Card都可以)即可運行。這種軟體在網上下載時一般是RAR或ZIP格式壓縮包,只需先在電腦上解壓,將解壓出來的文件夾拷貝到手機里即可運行。
4、Cpl文件,將文件直接拷貝到手機windows目錄下,即可在設置中出現相應的選項。如SoftKeyAppleEx.cpl對應會出現軟體設置選項。
參考資料:網路-手機軟體

③ 怎麼獲取android studio某個文件路徑

工具/原料

Android studio
方法/步驟

需要在項目中找到文件路徑,就需要在Android studio的項目中導入一個項目的文件。

並找到需要在電腦中需要的路徑位置,隨意選中一個文件。

進行點擊Android studio菜單中的Navigate的選項菜單。

彈出了下拉菜單中,進行選中下拉菜單中的「select in」的選項。

然後就會在當前的文件中彈出了一個下拉菜單框,進行選中下拉菜單中的show in explorer的選項。

然後進入到了電腦中文件夾位置中。

④ 怎麼將android 讀取文件路徑進行更改

android
sdk
安裝後默認會在我的文檔里生成一個.android文件夾,這個及時你的默認路徑.android\avd
打開一個。ini的
配置文件
target=android-7
path=(這就是你要修改的路徑)C:\
Documents
and
Settings\
Administrator
\.android\avd\test.avd

⑤ android 文件路徑怎麼寫

"./user_set"是Unix的寫法

Android寫法:
// SD卡存儲
SDPATH = Environment.getExternalStorageDirectory() + "/user_set";
// 內部存儲
FILESPATH = context.getFilesDir().getPath() + "/user_set";

⑥ android中怎麼獲取指定目錄下的文件夾

參考如下代碼:
package com.Aina.Android;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class Test_ListFile extends ListActivity {
/** Called when the activity is first created. */
private List<String> items = null;//存放名稱
private List<String> paths = null;//存放路徑
private String rootPath = "/";
private TextView tv;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView) this.findViewById(R.id.TextView);
this.getFileDir(rootPath);//獲取rootPath目錄下的文件.
}

public void getFileDir(String filePath) {
try{
this.tv.setText("當前路徑:"+filePath);// 設置當前所在路徑
items = new ArrayList<String>();
paths = new ArrayList<String>();
File f = new File(filePath);
File[] files = f.listFiles();// 列出所有文件
// 如果不是根目錄,則列出返回根目錄和上一目錄選項
if (!filePath.equals(rootPath)) {
items.add("返回根目錄");
paths.add(rootPath);
items.add("返回上一層目錄");
paths.add(f.getParent());
}
// 將所有文件存入list中
if(files != null){
int count = files.length;// 文件個數
for (int i = 0; i < count; i++) {
File file = files[i];
items.add(file.getName());
paths.add(file.getPath());
}
}

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, items);
this.setListAdapter(adapter);
}catch(Exception ex){
ex.printStackTrace();
}

}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
String path = paths.get(position);
File file = new File(path);
//如果是文件夾就繼續分解
if(file.isDirectory()){
this.getFileDir(path);
}else{
new AlertDialog.Builder(this).setTitle("提示").setMessage(file.getName()+" 是一個文件!").setPositiveButton("OK", new DialogInterface.OnClickListener(){

public void onClick(DialogInterface dialog, int which) {

}

}).show();
}
}

}

⑦ 如何獲取android項目下某個文件的絕對路徑

比如要獲取 要獲取libjnixcld.so絕對路徑
File file=new File("/data/data/com.dtBank.app.service/lib/libjnixcld.so")
簡單的說就是/data/data/packagename/你的文件夾名稱/文件名
非隱藏文件可以這樣獲取
以上方法只能獲取動態共享庫的絕對路徑
對於像minde.dat,public.dat以及其他一些文件獲取路徑的方式如下:
一,將文件放入assets文件夾下面(放入此文件夾下面的文件可通過InputStream in=context.getAssets().open("public.dat"));
獲得其二進制形式的流,具體例子如下
package com.dtBank.app.service;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import android.content.Context;
import android.os.Environment;
import android.util.Log;

/**
* 獲得加密文件的路徑
* @author hb
*
*/
public class getEncryptionFilePath {
class Obj{
InputStream in;
String fileDir;
String folder;
}
String lock="";
private void getCryptFilePath(Obj obj){
synchronized(lock){
try{
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
File cryptDir= new File(obj.folder);
Log.v("bb","創建的文件夾:"+obj.folder);
cryptDir.mkdirs();
OutputStream os= new FileOutputStream(obj.fileDir);
byte[] buf = new byte[1024*10];
int l;
Log.v("bb","開始寫文件");
InputStream in=obj.in;
while ((l = in.read(buf)) != -1) {
os.write(buf, 0, l);
os.flush();
}
Log.v("bb","文件已寫完");
os.close();
in.close();
}
}catch(Exception e){
e.printStackTrace();
}
}
}
// 調用此方法獲取文件在sdcard上面的絕對路徑
public void execute(Context context){
InputStream in=null;
OutputStream out=null;
try{
in =(context.getAssets().open("mixed.dat"));
String fileDir_mixed="/sdcard/xcloudmixed/mixed.dat";
final Obj obj=new Obj();
obj.in=in;
obj.fileDir=fileDir_mixed;
obj.folder="/sdcard/xcloudmixed";

new Thread(){
@Override
public void run(){
getCryptFilePath(obj);
}
}.start();

in =(context.getAssets().open("public.dat"));
String fileDir_public="/sdcard/xcloudpublic/public.dat";
final Obj obj1=new Obj();
obj1.in=in;
obj1.fileDir=fileDir_public;
obj1.folder="/sdcard/xcloudpublic";

new Thread(){
@Override
public void run(){
getCryptFilePath(obj1);
}
}.start();
}catch(Exception e){
e.printStackTrace();
}

}
}

⑧ android的項目里怎麼規定文件路徑的

方法一:把目標文件放入resources文件中,以通過讀取R的資源文件來獲取,具體方式如下:

1、在res下新建raw文件,將帶讀取文件添加到raw文件目錄下。

2、添加如下代碼:

// 如果要使用文件名獲取文件數據:首先獲取資源id然後再通過id獲取輸入流

InputStream im = getResources().openRawResource(R.raw.h_data11);

BufferedReader read = new BufferedReader(new InputStreamReader(im));

String line = "";

StringBuilder sb = new StringBuilder();

try {

while((line = read.readLine()) != null) {

sb.append(line).append("\n");

}

} catch (IOException e) {

e.printStackTrace();

} finally {

if(read != null) {

try {

read.close();

read = null;

} catch (IOException e) {

e.printStackTrace();

}

}

if(im != null) {

try {

im.close();

im = null;

} catch (IOException e) {

e.printStackTrace();

}

}

}

Log.v("", "result = " + sb.toString());

方法二:使用assets 只讀文件進行讀取。

1、將文件到assets下,可以新建文件夾如:「www」然後將文件放入www文件夾中,讀取的path為:"www/filename"

String result = "";

ObjectInputStream ois = null;

AssetManager am = context.getResources().getAssets();

try {

ois = new ObjectInputStream(am.open("www/filename"));

result = (String) ois.readObject();

} catch (StreamCorruptedException e) {

e.printStackTrace();

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

} catch (ClassNotFoundException e) {

e.printStackTrace();

} finally {

try {

if (ois != null) {

ois.close();

ois = null;

}

} catch (IOException e) {

e.printStackTrace();

}

}

以對象的方式讀取文件中的數據,如果沒有新建文件夾,把前面的「www/」去掉就ok啦

以上方式我都還有疑問的地方:
1、raw下新建多級目錄是否真的不能夠使用。

⑨ android 文件路徑問題

Environment.getDataDirectory().getPath() : /data

Environment.getDownloadCacheDirectory().getPath() : /cache
Environment.getExternalStorageDirectory().getPath() : /mnt/sdcard
Environment.getRootDirectory().getPath() : /system
Context.getCacheDir().getPath() : /data/data/包名/cache
Context.getExternalCacheDir().getPath() : /mnt/sdcard/Android/data/包名/cache
Context.getFilesDir().getPath() : /data/data/包名/files
Context.getObbDir().getPath() : /mnt/sdcard/Android/obb/包名
Context.getPackageName() : 包名
Context.getPackageCodePath() : /data/app/應用名
Context.getPackageResourcePath() : /data/app/應用名

這個是我以前在網上看過的,關於android中具體路徑與獲取方式之間對應關系的描述。

/data/data/cn.tony.app/files/這種路徑,可能是在包名為「cn.tony.app」的應用下,通過在Context的子類(Activity,Service等等)中調用getFilesDir所得到的。

而/mnt/sdcard/,應該是在4.0以下的android系統上,通過Environment類的getExternalStorageDirectory方法獲取的。

其實getExternalStorageDirectory這個方法,不如說是獲取默認存儲器的。在不同版本不同設置的android系統上,指向的位置也不太一樣。比如在4.0以上的系統上,它一般指向「storage/sdcard0」(內置SD卡),但也有廠家或個人把它設置為「storage/sdcard1」(外置SD卡)。就像window,系統一般是裝在C盤,但裝在D盤上其實也可以。

至於區別,我覺得主要是與外置SD卡有關。android4.4系統對外置SD卡做了一定限制。在它的設置中,手機內存儲(內置SD卡)屬於共有資源,只要有許可權,各種應用都能可以上面自由的讀寫文件夾和文件。而外置SD卡則管的比較嚴,它給每個第三方應用都劃了塊「個人空間」。就是「data/data/[包名]」目錄,應用只能在它自己的地盤上活動(操作文件)。舉例來說,如果我有個包名叫a的應用,它可以在內置SD卡上任意位置創建讀寫文件,而對於外置sd卡,則只能操作"data/data/a"目錄下的文件。這種方式文件結構比較清晰,同時還避免了一些隱患,刪除時也方便。

PS:有些4.4以上的手機,SD卡仍是一團亂。可能有兩個原因,一個是系統在SD卡上創建文件,這個是不受限的;還有一個就是上面說的,把默認設為了外存儲,純粹屬於把外置SD卡當內置SD使了。

熱點內容
伺服器提供什麼服務 發布:2024-05-06 21:45:20 瀏覽:211
一汽桌面雲伺服器地址 發布:2024-05-06 21:19:23 瀏覽:996
北京市社保官網登錄密碼是什麼 發布:2024-05-06 21:19:15 瀏覽:380
c語言數組的刪除 發布:2024-05-06 20:52:33 瀏覽:398
機械戰警用什麼配置好看 發布:2024-05-06 20:27:12 瀏覽:435
win10添加python環境變數 發布:2024-05-06 20:27:12 瀏覽:313
並聯臂演算法 發布:2024-05-06 20:02:11 瀏覽:623
cf跟dnf哪個需求配置高 發布:2024-05-06 20:01:23 瀏覽:657
什麼配置皮筋能打老鼠嗎 發布:2024-05-06 19:54:32 瀏覽:742
壓縮機油壓差報警 發布:2024-05-06 19:45:08 瀏覽:336