Skip to content

Instantly share code, notes, and snippets.

View mirkamalg's full-sized avatar
💡
In self-development mode

Mirkamal mirkamalg

💡
In self-development mode
View GitHub Profile
@RikkaW
RikkaW / gist:0ae7f51117768a03c6581c956d75958c
Last active June 18, 2024 05:31
insert general file with MediaStore
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());
@titoaesj
titoaesj / .kt
Last active June 5, 2024 12:34
Android convert int to dp
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