android系统中的app安装后的各个文件路径在哪里

android系统中的app安装后的各个文件路径在哪里,第1张

在系统中system/app文件夹中。

在android系统中安装软件时,系统会将其安装在设定好的路径当中,即system/app路径。后来下载的APP可以卸载,但系统自带的APP不能卸载,否则会引发系统的崩溃。

在安装APP时,也可以直接将文件复制到手机里(手机内存、Storage Card都可以),在手机上执行该CAB文件即可安装。

扩展资料

android系统中的app不同格式安装:

1、CAB格式,直接将文件copy到手机里,都可以在手机上执行该CAB文件即可安装。

2、EXE格式,EXE格式的程序可分为手机上直接运行(即绿色软件的形式)和连接电脑同步安装2种形式。

3、免安装软件(绿色软件),将文件直接拷贝到手机里(手机内存、Storage Card都可以)即可运行。这种软件在网上下载时一般是RAR或ZIP格式压缩包,只需先在电脑上解压,将解压出来的文件夹拷贝到手机里即可运行。

4、Cpl文件,将文件直接拷贝到手机windows目录下,即可在设置中出现相应的选项。如SoftKeyAppleExcpl对应会出现软件设置选项。

参考资料:

百度百科-手机软件

直接调用文件管理器选择即可。

1、调用系统提供的选择器,代码如下:

//注意,在Android44系统下建议使用 IntentACTION_OPEN_DOCUMENT方式

if (UtilityisKK()) {

Intent intent = new Intent(IntentACTION_OPEN_DOCUMENT);

intentaddCategory(IntentCATEGORY_OPENABLE);

intentsetType("image

public static String getDataColumn(Context context, Uri uri, String selection,

String[] selectionArgs) {

Cursor cursor = null;

final String column = "_data";

final String[] projection = {

column

};

处理返回结果:

protected void onActivityResult(int requestCode, int resultCode,

Intent intent) {

superonActivityResult(requestCode, resultCode, intent);

if (resultCode == RESULT_OK) {

switch (requestCode) {

case PIC_RESULT://选择图库

case PIC_RESULT_KK:

imageFileUri = intentgetData();//获取选择的URI

break;

2、除此自外,系统还提供一种选择器,这个选择器可以屏蔽掉那个auto backup的目录所以就开始打算用这个选择器来选了

Intent intent=new Intent(IntentACTION_GET_CONTENT);//ACTION_OPEN_DOCUMENT

intentaddCategory(IntentCATEGORY_OPENABLE);

intentsetType("image/jpeg");

if(androidosBuildVERSIONSDK_INT>=androidosBuildVERSION_CODESKITKAT){

startActivityForResult(intent, SELECT_PIC_KITKAT);

}else{

startActivityForResult(intent, SELECT_PIC);

}

为什么要分开不同版本呢其实在43或以下可以直接用ACTION_GET_CONTENT的,在44或以上,官方建议用ACTION_OPEN_DOCUMENT,主要区别是他们返回的Uri43返回的是带文件路径的,而44返回的却是content://comandroidprovidersmediadocuments/document/image:3951这样的,没有路径,只有编号的uri可以通过以下方式,处理URI。

参考:Android 44从图库选择,获取路径并裁剪

public static String getPath(final Context context, final Uri uri) {

final boolean isKitKat = BuildVERSIONSDK_INT >= BuildVERSION_CODESKITKAT;

// DocumentProvider

if (isKitKat && DocumentsContractisDocumentUri(context, uri)) {

// ExternalStorageProvider

if (isExternalStorageDocument(uri)) {

final String docId = DocumentsContractgetDocumentId(uri);

final String[] split = docIdsplit(":");

final String type = split[0];

if ("primary"equalsIgnoreCase(type)) {

return EnvironmentgetExternalStorageDirectory() + "/" + split[1];

}

// TODO handle non-primary volumes

}

// DownloadsProvider

else if (isDownloadsDocument(uri)) {

final String id = DocumentsContractgetDocumentId(uri);

final Uri contentUri = ContentUriswithAppendedId(

Uriparse("content://downloads/public_downloads"), LongvalueOf(id));

return getDataColumn(context, contentUri, null, null);

}

// MediaProvider

else if (isMediaDocument(uri)) {

final String docId = DocumentsContractgetDocumentId(uri);

final String[] split = docIdsplit(":");

final String type = split[0];

Uri contentUri = null;

if ("image"equals(type)) {

contentUri = MediaStoreImagesMediaEXTERNAL_CONTENT_URI;

} else if ("video"equals(type)) {

contentUri = MediaStoreVideoMediaEXTERNAL_CONTENT_URI;

} else if ("audio"equals(type)) {

contentUri = MediaStoreAudioMediaEXTERNAL_CONTENT_URI;

}

final String selection = "_id=";

final String[] selectionArgs = new String[] {

split[1]

};

return getDataColumn(context, contentUri, selection, selectionArgs);

}

}

// MediaStore (and general)

else if ("content"equalsIgnoreCase(urigetScheme())) {

// Return the remote address

if (isGooglePhotosUri(uri))

return urigetLastPathSegment();

return getDataColumn(context, uri, null, null);

}

// File

else if ("file"equalsIgnoreCase(urigetScheme())) {

return urigetPath();

}

return null;

}

public static String getDataColumn(Context context, Uri uri, String selection,

String[] selectionArgs) {

Cursor cursor = null;

final String column = "_data";

final String[] projection = {

column

};

try {

cursor = contextgetContentResolver()query(uri, projection, selection, selectionArgs,

null);

if (cursor != null && cursormoveToFirst()) {

final int index = cursorgetColumnIndexOrThrow(column);

return cursorgetString(index);

}

} finally {

if (cursor != null)

cursorclose();

}

return null;

}

public static boolean isExternalStorageDocument(Uri uri) {

return "comandroidexternalstoragedocuments"equals(urigetAuthority());

}

public static boolean isDownloadsDocument(Uri uri) {

return "comandroidprovidersdownloadsdocuments"equals(urigetAuthority());

}

public static boolean isMediaDocument(Uri uri) {

return "comandroidprovidersmediadocuments"equals(urigetAuthority());

}

public static boolean isGooglePhotosUri(Uri uri) {

return "comgoogleandroidappsphotoscontent"equals(urigetAuthority());

}

3、使用其它开源组件如PhotoView。

一、方法介绍:

每个Android应用程序都可以通过Context来获取与应用程序相关的目录,这些目录的功能各异,每一个目录都有自己的特点,有时候可能会搞混淆,本文结合android源码注释和实际 *** 作,详细介绍一下每个方法:

方法:getFilesDir

释义:返回通过ContextopenFileOutput()创建和存储的文件系统的绝对路径,应用程序文件,这些文件会在程序被卸载的时候全部删掉。

方法:getCacheDir

释义:返回应用程序指定的缓存目录,这些文件在设备内存不足时会优先被删除掉,所以存放在这里的文件是没有任何保障的,可能会随时丢掉。

方法:getDir

释义:这是一个可以存放你自己应用程序自定义的文件,你可以通过该方法返回的File实例来创建或者访问这个目录,注意该目录下的文件只有你自己的程序可以访问。

方法:getExternalCacheDir

释义:使用这个方法需要写外部存储的权限“”,调用该方法会返回应用程序的外部文件系统(EnvironmentgetExternalStorageDirectory())目录的绝对路径,它是用来存放应用的缓存文件,它和getCacheDir目录一样,目录下的文件都会在程序被卸载的时候被清除掉。

方法:getExternalFilesDir

释义:使用这个方法需要写外部存储的权限“”,这个目录是与应用程序相关的外部文件系统,它和getExternalCacheDir不一样的是只要应用程序存在它就会一直存在,这些文件只属于你的应用,不能被其它人访问。同样,这个目录下的文件在程序被卸载时也会被一同删除。

方法:getExternalFilesDir

释义:和上面的方法一样,只是返回的是其目录下某一类型的文件,这些类型可以是: Environment#DIRECTORY_MUSIC 音乐 Environment#DIRECTORY_PODCASTS 音频 Environment#DIRECTORY_RINGTONES 铃声 Environment#DIRECTORY_ALARMS 闹铃 Environment#DIRECTORY_NOTIFICATIONS 通知铃声 Environment#DIRECTORY_PICTURES Environment#DIRECTORY_MOVIES 视频

方法:getDatabasePath

释义:保存通过ContextopenOrCreateDatabase 创建的数据库文件

方法:getPackageCodePath

释义:返回android 安装包的完整路径,这个包是一个zip的压缩文件,它包括应用程序的代码和assets文件。

方法:getPackageResourcePath

释义:返回android 安装包的完整路径,这个包是一个ZIP的要锁文件,它包括应用程序的私有资源。

方法:getObbDir

释义:返回应用程序的OBB文件目录(如果有的话),注意如果该应用程序没有任何OBB文件,这个目录是不存在的。

二、测试程序:

测试代码如下:

private StringBuilder getFilePath( ){

StringBuilder filePathBuilder = new StringBuilder( );

// 返回通过ContextopenFileOutput()创建和存储的文件系统的绝对路径,应用程序文件,这些文件会在程序被卸载的时候全部删掉。

filePathBuilderappend( "getFilesDir == " )append( getFilesDir( ) )append( "\n" );

// 返回应用程序指定的缓存目录,这些文件在设备内存不足时会优先被删除掉,所以存放在这里的文件是没有任何保障的,可能会随时丢掉。

filePathBuilderappend( "getCacheDir == " )append( getCacheDir( ) )append( "\n" );

// 这是一个可以存放你自己应用程序自定义的文件,你可以通过该方法返回的File实例来创建或者访问这个目录,注意该目录下的文件只有你自己的程序可以访问。

filePathBuilderappend( "getDir == " )append( getDir("testtxt", ContextMODE_WORLD_WRITEABLE) )append( "\n" );

/ 需要写文件权限 /

// 调用该方法会返回应用程序的外部文件系统(EnvironmentgetExternalStorageDirectory())目录的绝对路径,它是用来存放应用的缓存文件,它和getCacheDir目录一样,目录下的文件都会在程序被卸载的时候被清除掉。

filePathBuilderappend( "getExternalCacheDir == " )append( getExternalCacheDir( ) )append( "\n" );

// 这个目录是与应用程序相关的外部文件系统,它和getExternalCacheDir不一样的是只要应用程序存在它就会一直存在,这些文件只属于你的应用,不能被其它人访问。同样,这个目录下的文件在程序被卸载时也会被一同删除。

filePathBuilderappend( "getExternalFilesDir == " )append( getExternalFilesDir( "/" ) )append( "\n" );

/

和上面的方法一样,只是返回的是其目录下某一类型的文件,这些类型可以是:

Environment#DIRECTORY_MUSIC 音乐

Environment#DIRECTORY_PODCASTS 音频

Environment#DIRECTORY_RINGTONES 铃声

Environment#DIRECTORY_ALARMS 闹铃

Environment#DIRECTORY_NOTIFICATIONS 通知铃声

Environment#DIRECTORY_PICTURES

Environment#DIRECTORY_MOVIES 视频

/

filePathBuilderappend( "getExternalFilesDir == " )append( getExternalFilesDir( EnvironmentDIRECTORY_PICTURES ) )append( "\n" );

// 保存通过ContextopenOrCreateDatabase 创建的数据库文件

filePathBuilderappend( "getDatabasePath == " )append( getDatabasePath( DATA_BASE_NAME ) )append( "\n" );

// 返回android 安装包的完整路径,这个包是一个zip的压缩文件,它包括应用程序的代码和assets文件

filePathBuilderappend( "getPackageCodePath == " )append( getPackageCodePath( ) )append( "\n" );

// 返回android 安装包的完整路径,这个包是一个ZIP的要锁文件,它包括应用程序的私有资源。

filePathBuilderappend( "getPackageResourcePath == " )append( getPackageResourcePath( ) )append( "\n" );

// 返回应用程序的OBB文件目录(如果有的话),注意如果该应用程序没有任何OBB文件,这个目录是不存在的。

filePathBuilderappend( "getObbDir == " )append( getObbDir( ) )append( "\n" );

return filePathBuilder;

}

android无法获取res资源文件夹路径,只能通过系统提供的封装函数访问。

资源文件夹有:

/res/drawable

,通过getresources()访问

/res/values

,通过getresources()访问

/res/layout,通过getresources()访问

/res/xml,通过getresources()访问

/res/raw,通过getresources()访问

/assets,通过getassets()访问

首先你获取到路径的字符串,然后分割就行了。

string

a

=

"/test/aaaa/bbbtxt";

string

b

=

asubstring(alastindexof("/")

+

1,

alength());

systemoutprintln(b);

这样之后,b字符串就是你所需要的。我的实现方法:用绝对路径和mediastore里的mediastoreaudiomediadata列进行比较

如果相同

就取出对应的mediastoreaudiomedia_id,然后uri就是uriparse("content://media/external/audio/media/"+id),这样就可以设置铃声了

// 获得存储卡的路径

String sdpath = EnvironmentgetExternalStorageDirectory() + "/";

String filename="歌词文件名";

String allpath=sdpath+filename;

StringBuffer sb = new StringBuffer();

File file = new File(allpath);

try {

BufferedReader br = new BufferedReader(new FileReader(file));

String line = "";

while((line = brreadLine())!=null)

{

sbappend(line);

}

brclose();

} catch (FileNotFoundException e) {

eprintStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

eprintStackTrace();

}

以上就是关于android系统中的app安装后的各个文件路径在哪里全部的内容,包括:android系统中的app安装后的各个文件路径在哪里、android怎么从sd卡指定的文件夹中获取所有图片的路径URL,谢谢~感谢各位大神了、验证文件路径的时候应该使用下面哪个方法来获取其路径等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/10138499.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-05
下一篇 2023-05-05

发表评论

登录后才能评论

评论列表(0条)

保存