0
사용자 지정 파일 확장자 (실제로 zip 파일)가있는 전자 메일을 수신하고 있습니다.Android 전자 메일 첨부 파일을 저장하려는 의도
첨부 파일을 예 : K9 이메일 앱을 내 앱의 캐시 디렉토리에 저장하면 zip 파일이 손상됩니다. 이 파일 관리자로 열리지
private void importData(Uri data) {
Log.d(TAG, data.toString());
final String scheme = data.getScheme();
if(ContentResolver.SCHEME_CONTENT.equals(scheme)) {
try {
ContentResolver cr = getApplicationContext().getContentResolver();
InputStream is = cr.openInputStream(data);
if(is == null) return;
StringBuffer buf = new StringBuffer();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String str;
if (is!=null) {
while ((str = reader.readLine()) != null) {
buf.append(str);
}
}
is.close();
File outputDir = getApplicationContext().getCacheDir(); // context being the Activity pointer
Log.d(TAG, "outputDir: " + outputDir.getAbsolutePath());
String fileName = "test_seed.zip";
Log.d(TAG, "fileName: " + fileName);
File zipFile = new File(outputDir, fileName);
FileWriter writer = new FileWriter(zipFile);
try {
writer.append(buf.toString());
writer.flush();
writer.close();
} catch (IOException e) {
Log.d(TAG, "Can't write to " + fileName, e);
} finally {
Toast.makeText(getApplicationContext(), "Zip key file saved to SDCard.", Toast.LENGTH_LONG).show();
}
// perform your data import here…
} catch(Exception e) {
Log.d("Import", e.getMessage(), e);
}
}
}
열린 문자열이 내 의도 필터입니다
content://com.fsck.k9.attachmentprovider/668da879-32c8-4143-a3ec-e135d901c443/31/VIEW
입니다 :
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:mimeType="application/*"
android:host="*"
android:pathPattern=".*\\.odks" />
</intent-filter>