This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OBS: O var_number_int é a varável que recebera o valor a ser convertido em DP | |
(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, var_number_int, getResources().getDisplayMetrics()) | |
##KOTLIN | |
val Int.dp: Int | |
get() = (this * Resources.getSystem().displayMetrics.density + 0.5f).toInt() | |
val Float.dp: Int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Context context = view.getContext(); | |
ContentResolver cr = context.getContentResolver(); | |
ContentValues values; | |
try { | |
// create a file for test | |
File file = new File(context.getFilesDir(), "1234568"); | |
file.createNewFile(); | |
try (OutputStream os = new FileOutputStream(file)) { | |
os.write("test".getBytes()); |