当前位置:首页 » 安卓系统 » 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使了。

热点内容
安卓系统怎么注册不了ins 发布:2024-05-19 14:01:00 浏览:960
买服务器后怎么搭建功能 发布:2024-05-19 14:00:03 浏览:207
windows文件夹图标下载 发布:2024-05-19 13:25:44 浏览:689
数据库存储数据类型 发布:2024-05-19 13:25:28 浏览:584
电脑开机密码忘记了如何解锁没有管理员窗口 发布:2024-05-19 13:24:50 浏览:277
畅捷支付刷脸机如何设置密码 发布:2024-05-19 13:03:10 浏览:764
java麻将 发布:2024-05-19 13:03:00 浏览:433
存储过程大数据游标 发布:2024-05-19 13:00:50 浏览:515
内存存储价格 发布:2024-05-19 13:00:48 浏览:389
隔离期的算法 发布:2024-05-19 12:55:13 浏览:530