Skip to content

Instantly share code, notes, and snippets.

View rukmaldias's full-sized avatar
🎯
Focusing

Rukmal Dias rukmaldias

🎯
Focusing
View GitHub Profile
// Usage:
// blacklist
String[] blacklist = new String[]{"com.any.package", "net.other.package"};
// your share intent
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "some text");
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "a subject");
// ... anything else you want to add
// invoke custom chooser
@rukmaldias
rukmaldias / EclipseShortCuts
Created November 11, 2014 09:36
Eclipse Short Cuts
* Go to method start *
CTRL + SHIFT + UP/DOWN
* GO to last viewed/cursor point *
ALT + LEFT/RIGHT
// request scan
Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
scanIntent.setData(Uri.fromFile(fileToDelete));
sendBroadcast(scanIntent);
@rukmaldias
rukmaldias / gist:c9ea7fda048d365a5092
Created October 29, 2014 05:40
RecursiveFileObserver
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import android.os.FileObserver;
public class RecursiveFileObserver extends FileObserver {
public static int CHANGES_ONLY = CLOSE_WRITE | MOVE_SELF | MOVED_FROM;
List<SingleFileObserver> mObservers;
String mPath;
private void copydb() {
try {
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
if (sd.canWrite()) {
String currentDBPath = "//data//abc.cde.package//databases//DatabaseName";
String backupDBPath = "database.db";
File currentDB = new File(data, currentDBPath);
File backupDB = new File(sd, backupDBPath);