档案文件; FileOutputStream fileOutputStream;
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = getPackageManager().queryIntentActivities(mainIntent, 0);
for (Object obj : pkgAppsList) {
ResolveInfo resolveInfo = (ResolveInfo) obj;
PackageInfo packageInfo = null;
try
{
file = new File(Environment.getExternalStorageDirectory(),"MyResearchFile.txt");
FileOutputStream fos = new FileOutputStream(file);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fos);
packageInfo = getPackageManager().getPackageInfo(resolveInfo.activityInfo.packageName, PackageManager.GET_PERMISSIONS);
String[] requestedPermissions = packageInfo.requestedPermissions;
final PackageManager pm = getApplicationContext().getPackageManager();
ApplicationInfo ai;
ai = pm.getApplicationInfo(resolveInfo.activityInfo.packageName,0);
final String applicationName = (String) (ai != null ? pm.getApplicationLabel(ai) : "unknown");
for (int i = 0,j=0; i < requestedPermissions.length; i++,j++)
{
if(requestedPermissions[i].contains("READ_CONTACTS") )
{
outputStreamWriter.append((applicationName + " requested " + requestedPermissions[i]).toString());
}
if(requestedPermissions[i].contains("WRITE_CONTACTS"))
{
outputStreamWriter.append((applicationName + " requested " + requestedPermissions[i]).toString());
}
}
outputStreamWriter.flush();
outputStreamWriter.close();
问题:追加功能不会将文本追加到文本文件中。我正在开发一个Android应用程序,它将所有权限详细信息写入文本文件。
答案 0 :(得分:6)
使用带有追加标志的构造函数
.Wrapper {
display:block;
margin: 0 auto;
width: 100%;
}
.gridButton {
padding: 10px;
background-color: #ff5100;
color: #ffffff;
margin: 5px;
float: left;
width: 250px;
text-align: center;
text-transform: uppercase;
}