List of usage examples for android.os Environment getExternalStoragePublicDirectory
public static File getExternalStoragePublicDirectory(String type)
From source file:com.cuddlesoft.nori.fragment.ImageFragment.java
/** * Use the system {@link android.app.DownloadManager} service to download the image. *//*w w w .j av a 2s.c om*/ protected void downloadImage() { // Get download manager system service. DownloadManager downloadManager = (DownloadManager) getActivity() .getSystemService(Context.DOWNLOAD_SERVICE); // Extract file name from URL. String fileName = image.fileUrl.substring(image.fileUrl.lastIndexOf("/") + 1); // Create download directory, if it does not already exist. //noinspection ResultOfMethodCallIgnored Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).mkdirs(); // Create and queue download request. DownloadManager.Request request = new DownloadManager.Request(Uri.parse(image.fileUrl)).setTitle(fileName) .setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName) .setVisibleInDownloadsUi(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // Trigger media scanner to add image to system gallery app on Honeycomb and above. request.allowScanningByMediaScanner(); // Show download UI notification on Honeycomb and above. request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); } downloadManager.enqueue(request); }
From source file:file_manager.Activity_files.java
private void setFilesList() { deleteDatabase("files_DB_v01.db"); String folder = sharedPref.getString("folder", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()); File f = new File(sharedPref.getString("files_startFolder", folder)); final File[] files = f.listFiles(); if (files == null || files.length == 0) { Snackbar.make(listView, R.string.toast_files, Snackbar.LENGTH_LONG).show(); } else {/* www . j a va2s . c o m*/ // looping through all items <item> for (File file : files) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()); String file_Name = file.getName(); String file_Size = getReadableFileSize(file.length()); String file_date = formatter.format(new Date(file.lastModified())); String file_path = file.getAbsolutePath(); String file_ext; if (file.isDirectory()) { file_ext = "."; } else { file_ext = file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf(".")); } db.open(); if (file_ext.equals(".") || file_ext.equals(".pdf") || file_ext.equals(".") || file_ext.equals(".jpg") || file_ext.equals(".JPG") || file_ext.equals(".jpeg") || file_ext.equals(".png")) { if (db.isExist(file_Name)) { Log.i(TAG, "Entry exists" + file_Name); } else { db.insert(file_Name, file_Size, file_ext, file_path, file_date); } } } } try { db.insert("...", "", "", "", ""); } catch (Exception e) { Snackbar.make(listView, R.string.toast_directory, Snackbar.LENGTH_LONG).show(); } //display data final int layoutstyle = R.layout.list_item; int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }; String[] column = new String[] { "files_title", "files_content", "files_creation" }; final Cursor row = db.fetchAllData(this); adapter = new SimpleCursorAdapter(this, layoutstyle, row, column, xml_id, 0) { @Override public View getView(final int position, View convertView, ViewGroup parent) { Cursor row2 = (Cursor) listView.getItemAtPosition(position); final String files_icon = row2.getString(row2.getColumnIndexOrThrow("files_icon")); final String files_attachment = row2.getString(row2.getColumnIndexOrThrow("files_attachment")); final String files_title = row2.getString(row2.getColumnIndexOrThrow("files_title")); final File pathFile = new File(files_attachment); View v = super.getView(position, convertView, parent); final ImageView iv = (ImageView) v.findViewById(R.id.icon_notes); iv.setVisibility(View.VISIBLE); if (pathFile.isDirectory()) { iv.setImageResource(R.drawable.folder); } else { switch (files_icon) { case ".gif": case ".bmp": case ".tiff": case ".svg": case ".png": case ".jpg": case ".JPG": case ".jpeg": try { Uri uri = Uri.fromFile(pathFile); Picasso.with(Activity_files.this).load(uri).resize(76, 76).centerCrop().into(iv); } catch (Exception e) { Log.w("HHS_Moodle", "Error Load image", e); } break; case ".pdf": iv.setImageResource(R.drawable.file_pdf); break; default: iv.setImageResource(R.drawable.arrow_up_dark); break; } } if (files_title.equals("...")) { new Handler().postDelayed(new Runnable() { public void run() { iv.setImageResource(R.drawable.arrow_up_dark); } }, 200); } return v; } }; //display data by filter final String note_search = sharedPref.getString("filter_filesBY", "files_title"); sharedPref.edit().putString("filter_filesBY", "files_title").apply(); filter.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s.toString()); } }); adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(CharSequence constraint) { return db.fetchDataByFilter(constraint.toString(), note_search); } }); listView.setAdapter(adapter); //onClick function listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) { Cursor row2 = (Cursor) listView.getItemAtPosition(position); final String files_icon = row2.getString(row2.getColumnIndexOrThrow("files_icon")); final String files_attachment = row2.getString(row2.getColumnIndexOrThrow("files_attachment")); final File pathFile = new File(files_attachment); if (pathFile.isDirectory()) { try { sharedPref.edit().putString("files_startFolder", files_attachment).apply(); setFilesList(); } catch (Exception e) { Snackbar.make(listView, R.string.toast_directory, Snackbar.LENGTH_LONG).show(); } } else if (files_attachment.equals("")) { try { final File pathActual = new File(sharedPref.getString("files_startFolder", Environment.getExternalStorageDirectory().getPath())); sharedPref.edit().putString("files_startFolder", pathActual.getParent()).apply(); setFilesList(); } catch (Exception e) { Snackbar.make(listView, R.string.toast_directory, Snackbar.LENGTH_LONG).show(); } } else if (files_icon.equals(".pdf")) { Uri uri = Uri.fromFile(pathFile); Intent intent = new Intent(Activity_files.this, MuPDFActivity.class); intent.setAction(Intent.ACTION_VIEW); intent.setData(uri); startActivity(intent); } else { helper_main.open(files_icon, Activity_files.this, pathFile, listView); } } }); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Cursor row2 = (Cursor) listView.getItemAtPosition(position); final String files_title = row2.getString(row2.getColumnIndexOrThrow("files_title")); final String files_attachment = row2.getString(row2.getColumnIndexOrThrow("files_attachment")); final File pathFile = new File(files_attachment); if (pathFile.isDirectory()) { Snackbar snackbar = Snackbar .make(listView, R.string.toast_remove_confirmation, Snackbar.LENGTH_LONG) .setAction(R.string.toast_yes, new View.OnClickListener() { @Override public void onClick(View view) { deleteRecursive(pathFile); setFilesList(); } }); snackbar.show(); } else { final CharSequence[] options = { getString(R.string.choose_menu_2), getString(R.string.choose_menu_3), getString(R.string.choose_menu_4) }; final AlertDialog.Builder dialog = new AlertDialog.Builder(Activity_files.this); dialog.setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); dialog.setItems(options, new DialogInterface.OnClickListener() { @SuppressWarnings("ResultOfMethodCallIgnored") @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.choose_menu_2))) { if (pathFile.exists()) { Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("image/png"); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, files_title); sharingIntent.putExtra(Intent.EXTRA_TEXT, files_title); Uri bmpUri = Uri.fromFile(pathFile); sharingIntent.putExtra(Intent.EXTRA_STREAM, bmpUri); startActivity(Intent.createChooser(sharingIntent, (getString(R.string.app_share_file)))); } } if (options[item].equals(getString(R.string.choose_menu_4))) { Snackbar snackbar = Snackbar .make(listView, R.string.toast_remove_confirmation, Snackbar.LENGTH_LONG) .setAction(R.string.toast_yes, new View.OnClickListener() { @Override public void onClick(View view) { pathFile.delete(); setFilesList(); } }); snackbar.show(); } if (options[item].equals(getString(R.string.choose_menu_3))) { AlertDialog.Builder builder = new AlertDialog.Builder(Activity_files.this); View dialogView = View.inflate(Activity_files.this, R.layout.dialog_edit_file, null); final EditText edit_title = (EditText) dialogView.findViewById(R.id.pass_title); edit_title.setText(files_title); builder.setView(dialogView); builder.setTitle(R.string.choose_title); builder.setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String inputTag = edit_title.getText().toString().trim(); File dir = pathFile.getParentFile(); File to = new File(dir, inputTag); pathFile.renameTo(to); pathFile.delete(); setFilesList(); } }); builder.setNegativeButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); AlertDialog dialog2 = builder.create(); // Display the custom alert dialog on interface dialog2.show(); helper_main.showKeyboard(Activity_files.this, edit_title); } } }); dialog.show(); } return true; } }); }
From source file:com.irccloud.android.IRCCloudApplicationBase.java
@Override public void onCreate() { super.onCreate(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) TrustKit.initializeWithNetworkSecurityConfiguration(getApplicationContext(), R.xml.network_security_config); Fabric.with(this, new Crashlytics()); Crashlytics.log(Log.INFO, "IRCCloud", "Crashlytics Initialized"); FlowManager.init(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); if (Build.VERSION.SDK_INT >= 19) EmojiCompat.init(//from ww w. j ava 2 s . co m new BundledEmojiCompatConfig(this).setReplaceAll(!prefs.getBoolean("preferSystemEmoji", true))); /*EmojiCompat.init(new FontRequestEmojiCompatConfig(getApplicationContext(), new FontRequest( "com.google.android.gms.fonts", "com.google.android.gms", "Noto Color Emoji Compat", R.array.com_google_android_gms_fonts_certs)) .setReplaceAll(!prefs.getBoolean("preferSystemEmoji", true)) .registerInitCallback(new EmojiCompat.InitCallback() { @Override public void onInitialized() { super.onInitialized(); EventsList.getInstance().clearCaches(); conn.notifyHandlers(NetworkConnection.EVENT_FONT_DOWNLOADED, null); } }));*/ NetworkConnection.getInstance().registerForConnectivity(); //Disable HTTP keep-alive for our app, as some versions of Android will return an empty response System.setProperty("http.keepAlive", "false"); //Allocate all the shared objects at launch conn = NetworkConnection.getInstance(); ColorFormatter.init(); if (prefs.contains("notify")) { SharedPreferences.Editor editor = prefs.edit(); editor.putString("notify_type", prefs.getBoolean("notify", true) ? "1" : "0"); editor.remove("notify"); editor.commit(); } if (prefs.contains("notify_sound")) { SharedPreferences.Editor editor = prefs.edit(); if (!prefs.getBoolean("notify_sound", true)) editor.putString("notify_ringtone", ""); editor.remove("notify_sound"); editor.commit(); } if (prefs.contains("notify_lights")) { SharedPreferences.Editor editor = prefs.edit(); if (!prefs.getBoolean("notify_lights", true)) editor.putString("notify_led_color", "0"); editor.remove("notify_lights"); editor.commit(); } if (!prefs.getBoolean("ringtone_migrated", false)) { if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { String notification_uri = prefs.getString("notify_ringtone", ""); if (notification_uri.startsWith("content://media/external/audio/media/")) { Cursor c = getContentResolver().query(Uri.parse(notification_uri), new String[] { MediaStore.Audio.Media.TITLE }, null, null, null); if (c != null && c.moveToFirst()) { if (c.getString(0).equals("IRCCloud")) { Log.d("IRCCloud", "Migrating notification ringtone setting: " + notification_uri); SharedPreferences.Editor editor = prefs.edit(); editor.remove("notify_ringtone"); editor.commit(); } } if (c != null && !c.isClosed()) { c.close(); } } File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_NOTIFICATIONS); File file = new File(path, "IRCCloud.mp3"); if (file.exists()) { file.delete(); } try { getContentResolver().delete(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, MediaStore.Audio.Media.TITLE + " = 'IRCCloud'", null); } catch (Exception e) { // Ringtone not in media DB } } try { String notification_uri = prefs.getString("notify_ringtone", ""); if (notification_uri.startsWith("content://media/")) { Cursor c = getContentResolver().query(Uri.parse(notification_uri), new String[] { MediaStore.Audio.Media.TITLE }, null, null, null); if (c != null && c.moveToFirst()) { if (c.getString(0).equals("IRCCloud")) { Log.d("IRCCloud", "Migrating notification ringtone setting: " + notification_uri); SharedPreferences.Editor editor = prefs.edit(); editor.remove("notify_ringtone"); editor.commit(); } } if (c != null && !c.isClosed()) { c.close(); } } } catch (Exception e) { //We might not have permission to query the media DB } try { getContentResolver().delete(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, MediaStore.Audio.Media.TITLE + " = 'IRCCloud'", null); } catch (Exception e) { // Ringtone not in media DB e.printStackTrace(); } File file = new File(getFilesDir(), "IRCCloud.mp3"); if (file.exists()) { file.delete(); } SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("ringtone_migrated", true); editor.commit(); } if (prefs.contains("notify_pebble")) { try { int pebbleVersion = getPackageManager().getPackageInfo("com.getpebble.android", 0).versionCode; if (pebbleVersion >= 553 && Build.VERSION.SDK_INT >= 18) { SharedPreferences.Editor editor = prefs.edit(); editor.remove("notify_pebble"); editor.commit(); } } catch (Exception e) { } } if (prefs.contains("acra.enable")) { SharedPreferences.Editor editor = prefs.edit(); editor.remove("acra.enable"); editor.commit(); } if (prefs.contains("notifications_json")) { SharedPreferences.Editor editor = prefs.edit(); editor.remove("notifications_json"); editor.remove("networks_json"); editor.remove("lastseeneids_json"); editor.remove("dismissedeids_json"); editor.commit(); } prefs = getSharedPreferences("prefs", 0); if (prefs.getString("host", "www.irccloud.com").equals("www.irccloud.com") && !prefs.contains("path") && prefs.contains("session_key")) { Crashlytics.log(Log.INFO, "IRCCloud", "Migrating path from session key"); SharedPreferences.Editor editor = prefs.edit(); editor.putString("path", "/websocket/" + prefs.getString("session_key", "").charAt(0)); editor.commit(); } if (prefs.contains("host") && prefs.getString("host", "").equals("www.irccloud.com")) { Crashlytics.log(Log.INFO, "IRCCloud", "Migrating host"); SharedPreferences.Editor editor = prefs.edit(); editor.putString("host", "api.irccloud.com"); editor.commit(); } if (prefs.contains("gcm_app_version")) { SharedPreferences.Editor editor = prefs.edit(); editor.remove("gcm_app_version"); editor.remove("gcm_app_build"); editor.remove("gcm_registered"); editor.remove("gcm_reg_id"); editor.commit(); } NetworkConnection.IRCCLOUD_HOST = prefs.getString("host", BuildConfig.HOST); NetworkConnection.IRCCLOUD_PATH = prefs.getString("path", "/"); /*try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) WebView.setWebContentsDebuggingEnabled(true); } } catch (Exception e) { }*/ /*FontRequest request = new FontRequest( "com.google.android.gms.fonts", "com.google.android.gms", "Dekko", R.array.com_google_android_gms_fonts_certs); FontsContractCompat.requestFont(getApplicationContext(), request, new FontsContractCompat.FontRequestCallback() { @Override public void onTypefaceRetrieved(Typeface typeface) { csFont = typeface; EventsList.getInstance().clearCaches(); NetworkConnection.getInstance().notifyHandlers(NetworkConnection.EVENT_FONT_DOWNLOADED, null); } }, getFontsHandler());*/ Crashlytics.log(Log.INFO, "IRCCloud", "App Initialized"); }
From source file:zlyh.dmitry.recaller.services.RecordService.java
private File getDir() { File storageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC), getString(R.string.recaller)); if (!storageDir.mkdirs()) { if (!storageDir.exists()) { storageDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), getString(R.string.recaller)); if (!storageDir.mkdirs()) { if (!storageDir.exists()) { //some low-end devices has no access no external storage storageDir = new File(RecallerApp.getAppContext().getExternalFilesDir(null), getString(R.string.recaller)); if (!storageDir.mkdirs()) { if (!storageDir.exists()) { storageDir = new File(RecallerApp.getAppContext().getFilesDir(), getString(R.string.recaller)); if (!storageDir.mkdirs()) { if (!storageDir.exists()) { return null; }//from w ww. j ava 2 s . co m } } } } } } } return storageDir; }
From source file:me.piebridge.prevent.ui.UserGuideActivity.java
private File getQrCode() { File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); if (dir == null) { return null; }/*from ww w . ja v a 2s . c om*/ if (!checkPermission()) { return null; } File screenshots = new File(dir, "Screenshots"); if (!screenshots.exists()) { screenshots.mkdirs(); } return new File(screenshots, "pr_donate.png"); }
From source file:com.tonyodev.fetch.request.Request.java
private static String generateDirectoryName() { return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString(); }
From source file:camera.AnotherCamera.java
/** * Creates the image file to which the image must be saved. * @return//from w ww. j a va 2 s .c o m * @throws IOException */ protected File createImageFile() throws IOException { // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_"; File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); File image = File.createTempFile(imageFileName, /* prefix */ ".jpg", /* suffix */ storageDir /* directory */ ); // Save a file: path for use with ACTION_VIEW intents CameraActivity activity = (CameraActivity) getActivity(); activity.setCurrentPhotoPath("file:" + image.getAbsolutePath()); return image; }
From source file:net.sarangnamu.scroll_capture.MainActivity.java
private void scrollCapture() { mProgress.setVisibility(View.VISIBLE); BkCfg.hideKeyboard(mUrl);// ww w. j av a2 s .c o m if (mLog.isDebugEnabled()) { String log = ""; log += "===================================================================\n"; log += "CAPTURE START\n"; log += "===================================================================\n"; mLog.debug(log); } new AsyncTask<Object, Integer, Boolean>() { Bitmap mBmp; @Override protected void onPreExecute() { int w, h; try { Picture pic = mWeb.capturePicture(); w = pic.getWidth(); h = pic.getHeight(); } catch (Exception e) { w = mWeb.getMeasuredWidth(); h = mWeb.getMeasuredHeight(); } mWeb.measure( View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); mBmp = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565); Canvas canvas = new Canvas(mBmp); mWeb.draw(canvas); } @Override protected Boolean doInBackground(Object... objects) { Context context = (Context) objects[0]; File dnPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); File ssPath = new File(dnPath, "screenshot"); if (!ssPath.exists()) { ssPath.mkdirs(); } String fileName = "test.png"; // DateFormat.format("yyyyMMdd-HHmmss", new Date()) + ".png"; File ssFile = new File(ssPath, fileName); try { FileOutputStream os = new FileOutputStream(ssFile); mBmp.compress(Bitmap.CompressFormat.PNG, 90, os); os.flush(); os.close(); sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + ssFile.getAbsolutePath()))); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return true; } @Override protected void onPostExecute(Boolean result) { if (mBmp != null) { mBmp.recycle(); mBmp = null; } if (mLog.isDebugEnabled()) { String log = ""; log += "===================================================================\n"; log += "CAPTURE END\n"; log += "===================================================================\n"; mLog.debug(log); } mProgress.setVisibility(View.GONE); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, MainActivity.this); }
From source file:com.app.swaedes.swaedes.ConstructionSitePage.java
public File getOutputAudioFile(int type) { //Create folder if it doesn't exist File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC), Config.APP_DIRECTORY_NAME);/* www. java 2 s. co m*/ if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Log.d(Config.APP_DIRECTORY_NAME, "Oops! Failed create" + Config.APP_DIRECTORY_NAME + "directory"); return null; } } //Audio title will be a timestamp to be unique audio_name = "REC_" + Config.timeStamp() + ".3gp"; File audioFile; if (type == MEDIA_TYPE_AUDIO) { audioFile = new File(mediaStorageDir + File.separator + audio_name); } else { return null; } return audioFile; }
From source file:com.awrtechnologies.carbudgetsales.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { this.requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); fragmentstack = new Stack<Fragment>(); // creating connection detector class instance cd = new ConnectionDetector(MainActivity.this); rl_buttons = (RelativeLayout) findViewById(R.id.relative_layout_buttons); relativeprogress = (RelativeLayout) findViewById(R.id.relativelayoutprogressbarheader); news = (ImageView) findViewById(R.id.button_news); deals = (ImageView) findViewById(R.id.button_deals); tools = (ImageView) findViewById(R.id.button_tools); inventory = (ImageView) findViewById(R.id.button_inventroy); info = (ImageView) findViewById(R.id.button_information); service = (ImageView) findViewById(R.id.button_services); facebook = (Button) findViewById(R.id.button_facebook); twitter = (Button) findViewById(R.id.button_twitter); google = (Button) findViewById(R.id.button_google); digg = (Button) findViewById(R.id.button_digg); youtube = (Button) findViewById(R.id.button_youtube); java.io.File imageFile1 = new File( (Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) + "/." + Constants.APPNAME + "")); imageFile1.mkdirs();// w ww . j av a 2 s . co m User user = User.getUser(); if (user != null) { if (GeneralHelper.getInstance(MainActivity.this).isIscheck() == true || GeneralHelper.getInstance(MainActivity.this).isIscheckdonetime() == true) { // openfragment(); // GeneralHelper.getInstance(com.awrtechnologies.carbudgetsales.MainActivity.this).setIscheckfragment(false); loadData(); } else if (GeneralHelper.getInstance(MainActivity.this).isIscheck() == false || GeneralHelper.getInstance(MainActivity.this).isIscheckdonetime() == false) { loadData(); } } else { // openNewFragment(new ServiceFragment()); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left); ft.replace(R.id.contanier, new Signin_fragment()); ft.commit(); } deals.setOnClickListener(this); inventory.setOnClickListener(this); news.setOnClickListener(this); tools.setOnClickListener(this); info.setOnClickListener(this); service.setOnClickListener(this); facebook.setOnClickListener(this); twitter.setOnClickListener(this); google.setOnClickListener(this); digg.setOnClickListener(this); youtube.setOnClickListener(this); }