Skip to content

Instantly share code, notes, and snippets.

public Cursor fetchRow (SQLiteDatabase readOnlyDatabase, long rowId, boolean archived, boolean isFavorite, String title) {
StringBuilder sqlStatement = new StringBuilder();
sqlStatement.append("SELECT * FROM " + COLUMN_RSS_FEED + " WHERE rowId = " + rowId);
if (archived != null) {
sqlStatement.append(" AND " + COLUMN_ARCHIVED + " = " + archived);
}
if (isFavorite) {
sqlStatement.append(" AND " + COLUMN_FAVORITE + " = " + isFavorite);
}
@sax1johno
sax1johno / gist:e69e7df7e50640432d5c
Last active August 29, 2015 14:21
Bloc Android welcome message template

Hey there -- first name --! Welcome to Bloc!

First and foremost, I wanted to thank you for choosing me as your mentor. I'm excited to get started and I know we're going to have a great journey together!

PERSONAL DETAILS FROM THEIR INTRODUCTION GOES HERE

Anyway, great to meet you!! I'm excited to get started and look forward to our first meeting.

Speaking of, here's the agenda moving forward:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:variablePadding="true" >
<item
android:drawable="@drawable/circle"
android:state_checked="true" />
<item
android:drawable="@drawable/square"
android:state_checked="false" />
</selector>
@sax1johno
sax1johno / gist:bab9ceb38e937aed5d06
Created June 4, 2015 18:21
Android version numbers, API Levels, and the Cyanogen Mod version.
Cyanogen Android API Level CodeName Release Date
12.1 5.1 22 Lollipop 2015 March
12 5.0 21 Lollipop 2014 November
4.4w 20 KitKat Wearable
11 4.4 19 KitKat 2013 September
10.2 4.3 18 Jelly Bean 2013 July
10.1 4.2 17 Jelly Bean 2012 November
10 4.1 16 Jelly Bean 2012 July
4.0.4, 4.0.3 15 Ice Cream Sandwich 2011 December
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Recurse
{
public static void main (String[] args) throws java.lang.Exception
```java
public class MyMap extends MapFragment {
GoogleMap myMap;
boolean mapReady = false;
.....
@Override
protected void onCreateView(LayoutInflater inflater, ViewGroup vg, Bundle savedInstanceState) {
getMapAsync(new OnMapReadyCallback() {
@Override
protected void onMapReady(GoogleMap map) {
public class MyActivity extends Activity {
Handler mHandler; // These are used to manage multiple threads in Android.
.....
@Override
protected void onCreate(Bundle savedInstanceState) {
mHandler = new Handler();
mHandler.post(new Runnable() {
@Override
public void run() {
// Do all of your network / facebook stuff in here
// Contact.java
public class Contact {
private String email;
private String name;
private String telephone;
/** ... getters and setters in here **/
}
URL apod = new URL(APOD_URL);
HttpURLConnection urlConnection = (HttpURLConnection) apod.openConnection();
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String jsonContent = br.readLine();
apodData = new JSONObject(jsonContent);