ファイルをアプリに関連付けるために、独自の拡張子「.swp」を使用しています。また、ユーザーがその拡張子のファイルを開こうとしているときに、アプリのオプションを取得できます。たとえば、sd カードのどこかに「file1.swp」というファイルがあり、ユーザーがそのファイルをクリックすると、そのアプリを開くためのオプション リストにもアプリが表示されます。しかし、アプリを選択して開くときに、「file1.swp」を一時フォルダーに保存したいと思います。
任意の提案をしてください........
ファイルをアプリに関連付けるために、独自の拡張子「.swp」を使用しています。また、ユーザーがその拡張子のファイルを開こうとしているときに、アプリのオプションを取得できます。たとえば、sd カードのどこかに「file1.swp」というファイルがあり、ユーザーがそのファイルをクリックすると、そのアプリを開くためのオプション リストにもアプリが表示されます。しかし、アプリを選択して開くときに、「file1.swp」を一時フォルダーに保存したいと思います。
任意の提案をしてください........
同じ質問をしている他の人が参照できるように、コード全体を以下に投稿しています。
String strFilename = "Not set";
Intent intent = getIntent();
if(intent != null)
{
Uri uri = intent.getData();
if(uri != null)
{
strFilename = intent.getData().getPath();
String NameOfFile = intent.getDataString();
Toast.makeText(SplashActivity.this, "strFilename" + strFilename + "" + "Name of file is::" + NameOfFile, Toast.LENGTH_LONG).show();
System.out.println("strFileName::"+ strFilename );
System.out.println("NameOfFile::"+ NameOfFile );
try {
copyFile(strFilename,"/mnt/sdcard/Profile.swp");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else{
}
}
//copy file into other location
private void copyFile(String assetFilename, String outFileName ) throws IOException{
System.out.println("outFileName ::" + outFileName);
//Open your local db as the input stream
InputStream myInput = new FileInputStream(assetFilename);
//Open the empty db as the output stream
OutputStream myOutput = new FileOutputStream(outFileName);
//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[2048];
int length;
while ((length = myInput.read(buffer))>0){
myOutput.write(buffer, 0, length);
}
//Close the streams
myOutput.flush();
myOutput.close();
myInput.close();
}