mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-23 07:27:22 +01:00
save downloaded .apks in private dir
Don't need File permission now. Files will pile up unseen now, so need to add delete logic eventually.
This commit is contained in:
parent
99f0c09d06
commit
34d5ef291c
2 changed files with 13 additions and 6 deletions
|
@ -139,7 +139,7 @@ public class DwnldDelegate extends ListDelegateBase {
|
|||
InputStream is = conn.getInputStream();
|
||||
String name = basename( m_uri.getPath() );
|
||||
if ( m_isApp ) {
|
||||
m_appFile = saveToDownloads( is, name, this );
|
||||
m_appFile = saveToPrivate( is, name, this );
|
||||
} else {
|
||||
m_savedDict = saveDict( is, name, this );
|
||||
}
|
||||
|
@ -200,14 +200,18 @@ public class DwnldDelegate extends ListDelegateBase {
|
|||
});
|
||||
}
|
||||
|
||||
private File saveToDownloads( InputStream is, String name,
|
||||
DictUtils.DownProgListener dpl )
|
||||
private File saveToPrivate( InputStream is, String name,
|
||||
DictUtils.DownProgListener dpl)
|
||||
{
|
||||
File appFile = null;
|
||||
boolean success = false;
|
||||
File appFile = new File( DictUtils.getDownloadDir( m_activity ), name );
|
||||
|
||||
byte[] buf = new byte[1024*4];
|
||||
|
||||
try {
|
||||
// directory first
|
||||
appFile = new File(m_activity.getFilesDir(), "apks");
|
||||
appFile.mkdirs();
|
||||
appFile = new File( appFile, name );
|
||||
FileOutputStream fos = new FileOutputStream( appFile );
|
||||
boolean cancelled = false;
|
||||
for ( ; ; ) {
|
||||
|
@ -325,7 +329,9 @@ public class DwnldDelegate extends ListDelegateBase {
|
|||
DictUtils.DictLoc loc = XWPrefs.getDefaultLoc( m_activity );
|
||||
|
||||
for ( DownloadFilesTask task : m_dfts ) {
|
||||
if ( task.forApp() || DictUtils.DictLoc.DOWNLOAD == loc ) {
|
||||
if ( task.forApp() ) {
|
||||
// Needn't do anything
|
||||
} else if ( DictUtils.DictLoc.DOWNLOAD == loc ) {
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<external-path name="external_files" path="."/>
|
||||
<files-path name="internal_files" path="apks/"/>
|
||||
</paths>
|
||||
|
|
Loading…
Add table
Reference in a new issue