mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
add (unused) method to copy apk to Downloads/
This commit is contained in:
parent
9fd4bb2a11
commit
c3b1423c36
1 changed files with 29 additions and 1 deletions
|
@ -22,13 +22,15 @@ package org.eehouse.android.xw4;
|
||||||
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteConstraintException;
|
import android.database.sqlite.SQLiteConstraintException;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
import android.database.sqlite.SQLiteStatement;
|
import android.database.sqlite.SQLiteStatement;
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.Bitmap.CompressFormat;
|
import android.graphics.Bitmap.CompressFormat;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
@ -2563,6 +2565,32 @@ public class DBUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy my .apk to the Downloads directory, from which a user could more
|
||||||
|
// easily share it with somebody else. Should be blocked for apks
|
||||||
|
// installed from the Play store since viral distribution isn't allowed,
|
||||||
|
// but might be helpful in other cases. Need to figure out how to expose
|
||||||
|
// it, and how to recommend transmissions. E.g. gmail doesn't let me
|
||||||
|
// attach an .apk even if I rename it.
|
||||||
|
static void copyApkToDownloads( Context context )
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
String myName = context.getPackageName();
|
||||||
|
PackageManager pm = context.getPackageManager();
|
||||||
|
ApplicationInfo appInfo = pm.getApplicationInfo( myName, 0 );
|
||||||
|
|
||||||
|
File srcPath = new File( appInfo.publicSourceDir );
|
||||||
|
File destPath = Environment
|
||||||
|
.getExternalStoragePublicDirectory( Environment.DIRECTORY_DOWNLOADS );
|
||||||
|
destPath = new File( destPath, context.getString(R.string.app_name) + ".apk" );
|
||||||
|
|
||||||
|
FileInputStream src = new FileInputStream( srcPath );
|
||||||
|
FileOutputStream dest = new FileOutputStream( destPath );
|
||||||
|
copyFileStream( dest, src );
|
||||||
|
} catch ( Exception ex ) {
|
||||||
|
Log.e( TAG, "copyApkToDownloads(): got ex: %s", ex );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static String getVariantDBName()
|
private static String getVariantDBName()
|
||||||
{
|
{
|
||||||
return String.format( "%s_%s", DBHelper.getDBName(),
|
return String.format( "%s_%s", DBHelper.getDBName(),
|
||||||
|
|
Loading…
Reference in a new issue