『壹』 android 文件路径问题
一个是应用的文件目录
一个是sdk的文件路径
『贰』 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系统中的app安装后的各个文件路径在哪里
在系统中system/app文件夹中。
在android系统中安装软件时,系统会将其安装在设定好的路版径当中,即system/app路径。后来下权载的APP可以卸载,但系统自带的APP不能卸载,否则会引发系统的崩溃。
在安装APP时,也可以直接将文件复制到手机里(手机内存、Storage Card都可以),在手机上执行该CAB文件即可安装。
(3)android文件中文路径扩展阅读
android系统中的app不同格式安装:
1、CAB格式,直接将文件到手机里,都可以在手机上执行该CAB文件即可安装。
2、EXE格式,EXE格式的程序可分为手机上直接运行(即绿色软件的形式)和连接电脑同步安装2种形式。
3、免安装软件(绿色软件),将文件直接拷贝到手机里(手机内存、Storage Card都可以)即可运行。这种软件在网上下载时一般是RAR或ZIP格式压缩包,只需先在电脑上解压,将解压出来的文件夹拷贝到手机里即可运行。
4、Cpl文件,将文件直接拷贝到手机windows目录下,即可在设置中出现相应的选项。如SoftKeyAppleEx.cpl对应会出现软件设置选项。
『肆』 android系统中的app安装后的各个文件路径在哪里
工作路径在data/data/,但是不是像你说的那样都解压出来,你可以去哪个目录看看
查看原帖>>
『伍』 android 文件路径怎么写
"./user_set"是Unix的写法
Android写法:
// SD卡存储
SDPATH = Environment.getExternalStorageDirectory() + "/user_set";
// 内部存储
FILESPATH = context.getFilesDir().getPath() + "/user_set";
『陆』 如何写android指定文件路径
Android根据路径打开文件夹的步骤:
1、android系统内置了很多应用,包括电话拨号,短信,浏览器等,这里创建一个简单的Android程序,调用内置的浏览器打开指定的地址。
2、对应的layout xml为:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/btnGo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="46dp"
android:text="@string/btnTitle_go" />
<EditText
android:id="@+id/txtUri"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btnGo"
android:layout_alignBottom="@+id/btnGo"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/btnGo"
android:ems="10"
android:text="http://junqilian.cnblogs.com" >
<requestFocus />
</EditText>
</RelativeLayout>
3、Java代码实现如下,主要是给EditText添加一个OnKeyListener,处理在editText里面按回车键,给button添加一个onClickListener,触发到OpenBroswer函数,通过intent打开内置的浏览器。