Skip to content

Instantly share code, notes, and snippets.

File file = new File(getPath(uri));
public String getPath(Uri uri)
{
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null);
if (cursor == null) return null;
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
@Collosteam
Collosteam / gist:ffcdfcf6cf10f737a280
Created October 23, 2014 19:26
Android Uri to File new API (11+)
public String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] projection = {MediaStore.Images.Media.DATA};
cursor = context.getContentResolver().query(contentUri, projection, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
} finally {
if (cursor != null) {
class Program
{
static void Main(string[] args)
{
int row = 0;
int[,] xoarrey = new int[,]{ { 0, 1, 2 }, { 0, 2, 0 } ,{ 0, 1, 1 } };
for (int i = 0; i < 5; i++) {
if (i % 2 == 0)
{
@Collosteam
Collosteam / gist:e2cb6a904aa79b0ed746
Created November 7, 2014 22:02
Android Edit text limit
EditText input = ...
InputFilter[] FilterArray = new InputFilter[1];
FilterArray[0] = new InputFilter.LengthFilter(limit);
input.setFilters(FilterArray);
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="src" exported="true" path="/Best_Buttons_The" combineaccessrules="false"/>
<classpathentry kind="output" path="bin/classes"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="lib" exported="true" path="/Best_Buttons_The/libs/gdx.jar" sourcepath="/Best_Buttons_The/libs/gdx-sources.jar"/>
<classpathentry kind="lib" exported="true" path="libs/gdx-backend-android.jar" sourcepath="libs/gdx-backend-android-sources.jar"/>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="src" exported="true" path="/Best_Buttons_The" combineaccessrules="false"/>
<classpathentry kind="output" path="bin/classes"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="lib" exported="true" path="/Best_Buttons_The/libs/gdx.jar" sourcepath="/Best_Buttons_The/libs/gdx-sources.jar"/>
<classpathentry kind="lib" exported="true" path="libs/gdx-backend-android.jar" sourcepath="libs/gdx-backend-android-sources.jar"/>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="src" exported="true" path="/Best_Buttons_The" combineaccessrules="false"/>
<classpathentry kind="output" path="bin/classes"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="lib" exported="true" path="/Best_Buttons_The/libs/gdx.jar" sourcepath="/Best_Buttons_The/libs/gdx-sources.jar"/>
<classpathentry kind="lib" exported="true" path="libs/gdx-backend-android.jar" sourcepath="libs/gdx-backend-android-sources.jar"/>