Code example for File

Methods: fromFile

0
	} 
	 
	public static void installAPK(Context context, final String url) {		
	    Intent intent = new Intent(Intent.ACTION_VIEW);  
		String fileName = APK_ROOT + getFileNameFromUrl(url);
		intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");     
		intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);       
		intent.setClassName("com.android.packageinstaller",       
		                    "com.android.packageinstaller.PackageInstallerActivity");        
		context.startActivity(intent);
	} 
	 
	//SDcard 操作   
	public static boolean isSdCardWrittenable() { 
	    if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
		return true; 
	    } 
	    return false; 
	} 
 
Experience pair programming with AI  Get Codota for Java